Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

How to localize month names in dxDateBox (dxCalendar, dxPivotGrid)

$
0
0
This example illustrates how to localize the dxDateBox day and month names and a date format. This example uses the German culture from the globalize culture libraries.

NOTE: The globalize.culture.XX.js dictionary as well as all the dictionary files must be linked above the corresponding DevExtreme dictionary. 

How to apply conditional formatting to Grid cells using the Icon Ranges format condition

$
0
0

Range conditions (FormatConditionRangeSet) allow you to use predefined or custom sets of icons/colors to apply conditional formatting to different ranges of values.

This example shows how to apply conditional formatting to Grid cells using a predefined set of icons. Use the Update Formatting button to change the number of ranges, specify new range boundaries and customize icons corresponding to existing ranges.

Syntax highlighting technique that uses hash table for searching

$
0
0

Please review the E2993: Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens example instead, if you use v2010 vol.2.6 and later.

This example illustrates the use of the service based on the ISyntaxHighlightService interface. This service is called every time the document content is changed. Then you can analyze the content and highlight required words in a document.
The Execute method of the service uses hash table instead of the straightforward search.

Question Comments

Added By: Anders Wang at: 6/25/2015 1:59:07 AM    

Hi,
This sample cannot work now, Could you please update it? Thanks.

Added By: Andrey (DevExpress Support) at: 6/25/2015 4:41:48 AM    

Hello,
Would you please describe the issue in greater detail and specify the version you are using?
Take special note of the Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens example that was mentioned above if you are using v2010 vol.2.6 and later.

How to apply conditional formatting to Grid cells using the Gradient Ranges format condition

$
0
0

The Range Gradient condition (FormatConditionRangeGradient) allows you to use predefined color gradients to apply conditional formatting to different ranges of values.

This example shows how to apply conditional formatting to Grid cells using the predefined Red-Blue color gradient. Use the Update Formatting button to change start/end colors and the number of ranges in the color gradient. The third color in the middle of the color scale is also specified to generate a 3-color gradient.

How to use dashboard parameters with the Expression format condition

$
0
0

The Expression format condition (FormatConditionExpression) allows you to use complex conditions to apply formatting.
This example demonstrates how to pass a dashboard parameter to an expression used to apply conditional formatting. You can specify the required parameter value to apply formatting dynamically.

WorkspaceManager - How to use WorkspaceManager for capturing, applying, saving and loading workspaces

$
0
0

This example demonstrates how to use standalone Workspace Manager API for capturing, applying, saving and loading workspaces and shows different Transition Types in action. 
You can find the general information about the WorkspaceManager in our documentation: Workspace Manager

Note that the Workspace Manager provides a bar menu, represented by the BarWorkspaceMenuItem class to assist both you and your end-users in creating, saving and loading workspaces. This item can be added to the required Bar or RibbonControl.

How to customize an XPO business model at runtime (Example)

$
0
0

Sometimes there is a requirement to extend existing business classes from other libraries, add new members, etc.

For instance, you have an assembly where you have declared your persistent classes. Now, you want to use these classes in your XAF application.

Note that to use the types from external assemblies, you should add them to your business model. To do that, you should use the Business Classes section of the Module Designer.


For instance, to force XAF to create navigation items for business classes, usually you can mark them with the DevExpress.Persistent.Base.DefaultClassOptionsAttribute, but what to do if your classes "live" in a separate assembly, which has no references to DevExpress.ExpressApp assemblies.

What to do? In this instance, the XafTypesInfo / XPDictionary customization may be helpful. Currently in XAF using this approach, you can add new attributes to your classes and their members, declare new associations, etc. The only thing, which is not currently supported in XAF, by default, is the capability to declare new classes "on the fly" via customization of the XafTypesInfo / XPDictionary. 

IMPORTANT NOTES

1. By design you cannot dynamically add or remove the OptimisticLocking and DeferredDeletion attributes.
2. Adding custom members for Domain Components (DC) should be done on the XafApplication.SettingUp event as described at How do I define a custom member for a domain component (DC) at runtime?.

3. For XAF versions older than 15.1.4 you cannot dynamically establish an association between two persistent classes via the XafTypesInfo API. Use the XPDictionary API instead as shown in this example.

Starting with v15.1.4, use the solution described in the eXpressApp Framework > Concepts > Business Model Design > Types Info Subsystem > Customize Business Object's Metadata > Create Associations in Code article.


See also:
How to: Access Business Class Metadata

Question Comments

Added By: Denis S at: 11/15/2013 5:58:17 AM    

Update the MyXPOClassLibrary project from Framework 3.0 to 4.0, in order to compile.

How to implement T-SQL language syntax highlighting by creating Syntax Highlight Tokens manually

$
0
0

This example illustrates how to implement simplified syntax highlighting for the T-SQL language by registering the ISyntaxHighlightService. Note that we do not use the DevExpress.CodeParser library in this example. Text is parsed into tokens (a list of SyntaxHighlightToken Class instances) manually in the CustomSyntaxHighlightService.ParseTokens() method. The resulting list is sorted (see Documentation - It is not mentioned that a list passed to the SubDocument.ApplySyntaxHighlight method should be sorted) and passed to the SubDocument.ApplySyntaxHighlight Method.

See Also:
Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens - Syntax highlighting for C# and VB code using DevExpress CodeParser and Syntax Highlight tokens

Question Comments

Added By: Roland Radlmair at: 6/6/2013 1:35:59 AM    

Hi,

could you also add the functionality for highlighting comments like "// this is a comment".

That would be great!
Thanks.

Added By: Martijn Loeffen at: 3/3/2014 8:32:11 AM    

This example throws an exception when running with DevExpress 2013.1.9 and 2013.2.7. A workaround is to replace the order of the folowing lines:

richEditControl1.ReplaceService<ISyntaxHighlightService>(new CustomSyntaxHighlightService(richEditControl1.Document));
richEditControl1.LoadDocument("CarsXtraScheduling.sql");

There still remains an issue, because another document cannot be loaded: it still throws an exception.

Added By: Anders Wang at: 6/25/2015 8:47:48 PM    

public void Execute() {
           document.ApplySyntaxHighlight(ParseTokens());
       }

Hi,
it is not so correct way to call ParseTokens() each time when need ApplySyntaxHighlight. You can try it with increase the keywords array to above 200-500. The tokens should be initialized when the docment loaded. After then, it should be updated incrementally and should not be build each time.

Added By: Andrey (DevExpress Support) at: 6/26/2015 5:25:32 AM    

Hello,
I have discussed this behavior with our developers and we have come to the conclusion that this behavior is by design.
For now, we are not planning to change it in the near future.


ComboBox - How to display items with images

SimpleButton - How to provide custom back color for each state when the Style property is set to UltraFlat

$
0
0
This example illustrates how to change SimpleButton's back color for each state (Normal, Hot track, Pressed, Disabled, Focused) in UltraFlat style
Question Comments

Added By: Mark Callahan at: 6/26/2015 9:11:32 AM    

How apply this to specific button with style property in UltraFlat, not all in the form. ??

Thanks.

XRTable - How to best fit columns

$
0
0

Currently, XRTable does not provide the best fit column functionality for several reasons. It is not quite clear how this feature should work in the case of multi-line text in cells. Being applied to a grid, the best-fit feature resizes grid columns so you can use the horizontal scrollbar to reach all of them. Reports does not provide interactivity like content scrolling and it is difficult to foresee how a user would want to change the report layout in the case of large column content. 

For these reasons, a generic solution is not always possible. However, we can implement this manually if required. This example demonstrates how to do so. 

Here are implementation details.
1. Create a document by using the Report's CreateDocument Method.
2. Iterate through all report bricks to obtain the maximum text width within a certain column.
Since XRTable rows act independently and know nothing about each other, to detect the max width of the text in a certain column, we need to iterate through report table bricks manually (for instance, using BricksIterator) and calculate the text width (using the PrintingSystem.Graph.MeasureString method).
3. Re-set the XRTableCell's WidthF property according to calculation results.
4. Re-create the report document.

See also:
How to set the label width so that it is always equal to its text (AutoWidth)
Customizing row height at runtime to a maximum best fit value

How to use dxSparkline inside ASPxGridView Cells / DataItemTemplate

$
0
0
This example is based on this demo.
It illustrates how to use the dxSparkline Data Visualization Widget in ASPxGridView Cells / DataItemTemplate:
- Define a custom HTML element with the specified "class" (for example, "elementClassToSelect" in order to access it via a selector on the client) and runat=server (in order to access it on the server) attributes and specified dimensions inside the DataItemTemplate;
- Use the K18282: The general technique of using the Init/Load event handler approach and handle this HTML element's Init event;
- Specify element's attribute (for example, "data") with some data (for example, the related record's one). Use the standard System.Web.Script.Serialization.JavaScriptSerializer.Serialize method to create a JSON string from an IEnumerable source.
- Handle the ASPxClientGridView Init/EndCallback events and initialize the dxSparkline widget (see the K18561: Using jQuery / jQuery UI libraries with DevExpress ASP.NET Controls / MVC Extensions #3):
    - Select all targets to be transformed to dxSparkline via a class selector (according to the class attribute specified earlier);
    - Transform all targets to the dxSparkline widget:
        - Use the base settings for creating a dxSparkline widget;
        - Specify an individual "dataSource" property retrieved from the element's ("data") attribute;
        - Remove the ("data") attribute from the transformed element (if necessary).

How to use ASPxRichEdit to edit RTF data in ASPxGridView's EditForm

$
0
0
This example is based on the How to use ASPxHtmlEditor to edit RTF data one. It illustrates how to accomplish the same task using a new ASPxRichEdit control instead of the ASPxHtmlEditor one:
- Add ASPxRichEdit into the related column's EditItemTemplate;
- Handle the ASPxRichEdit.Init event.
- When editing an existing row, use the corresponding ASPxRichEdit.Open method overload;
    - Pass the documentId value to identify the document to open (for example, generated based on the editing row index/key);
    - Return a stream or an array of bytes value from the 3-rd parameter created from the underlying column value;
- Handle the ASPxGridView RowInserting/RowUpdating events:
    - Retrieve the modified rich text content from ASPxRichEdit via the ASPxRichEdit.SaveCopy method;
    - Save it back to the database in the required format (a string or an array of bytes value).

Note that data modifications are not allowed in online demos. To allow editing in local/offline mode, download the example and comment out the "throw..." operation in the ASPxGridView.RowUpdating event handler.

See Also:
How to use ASPxHtmlEditor to edit RTF data

How to use ASPxHtmlEditor to edit RTF data

$
0
0

Important Note

In version 14.1 we've developed a great new ASP.NET editor that may better fit your scenario. Read more about the new ASPxRichEdit here: https://community.devexpress.com/blogs/aspnet/archive/2014/11/12/asp-net-word-inspired-rich-text-editor-preview-release-coming-soon.aspx


How to use ASPxRichEdit to edit RTF data in ASPxGridView's EditForm

For previous versions:

It is possible to use ASPxHtmlEditor WYSIWYG capabilities to edit rich text, for example, imported from the RTF file.

This example illustrates how to:

- Store real RTF content in a data source;

- Edit this RTF content within ASPxHtmlEditor.

The StandaloneEditor page:

When a page is loaded for the first time, ASPxHtmlEditor imports either RTF content saved in the Session state or a real RTF document located on a web server via the ASPxHtmlEditor.Import method.

An end-user is able to click the custom ASPxHtmlEditor toolbar item to save the changes. To retrieve the modified rich content from the HTML Editor the ASPxHtmlEditor.Export method is used.

The GridEditor page:

- ASPxHtmlEditor is placed into a column’s EditItemTemplate;

- The ASPxHtmlEditor content is populated by handling the ASPxHtmlEditor.Init event: A real column’s RTF data is imported via the ASPxHtmlEditor.Import method.

- When an end-user clicks the Update button, the ASPxGridView.RowUpdating event is raised;

- A reference to the ASPxHtmlEditor is retrieved via the ASPxGridView.FindEditRowCellTemplateControl method;

- A modified RTF content is retrieved from the ASPxHtmlEditor.Html via the ASPxHtmlEditor.Export method and passed back to the datasource.

- Clicking the “More Info” link invokes ASPxPopupControl, which populates its content via its built-in callback functionality. The popup loads the clicked row’s RTF content transformed to the HTML via our cross-platform RichEditDocumentServer engine.

Please note that this example can't run on the Web because it requires file creation during its running, but the file creation is prevented on our example server.

How to save the currently opened View as a new View Variant at runtime

$
0
0

This example provides reusable UserViewVariants modules that allow your end-users to add View Variants dynamically. Refer to the Best practices of creating reusable XAF modules by example of a View Variants module extension blog post for more information. See functional tests for the implemented functionality in the UserViewVariants\Functional Tests\E2813.ets file.


IMPORTANT NOTES
Due to the application model generation specifics on the Web it makes sense to use this solution on the Web only if you store your end-user model differences in the database: How to store users' model differences separately for each user in the database.


See also:

ViewVariants - provide the capability to save the current view as a new view variant and share it with other users at runtime

Question Comments

Added By: Robert Fuchs at: 9/2/2013 1:36:24 PM    

Modified today but still not for 13.1 !?
Why?

Added By: Dennis (DevExpress Support) at: 9/3/2013 12:16:43 AM    

Robert, this example was already available for version 13.1 before today. Today was just a maintenance update without much changes.

Added By: Robert Fuchs at: 9/3/2013 10:12:12 AM    

Thanks Dennis.
Interestingly the version combo didn't show 13.1 yesterday.
I downloaded it anyway and it worked in 13.1 after changing .Net FW type to 4.

Added By: Richard Jones_1 at: 12/11/2013 1:04:47 PM    

Hello, This is a great solution, but after upgrading to 13.2 it does not compile, Do you have a version for 13.2?
Thanks
Richard

Added By: Nektarios Patelis at: 12/13/2013 12:35:47 AM    

waiting upgrade for 13.2

Added By: Willem de Vries at: 1/8/2014 8:49:14 AM    

Just leaving a comment to be included in any update messages. Waiting for a remedy for this breaking change to be able to upgrade to 13.2 with many of my applications.

Added By: Tony Tadros at: 1/14/2014 9:52:19 AM    

i have a suggestion to support such functionality of of the box

Added By: Stefan Tschiharz at: 1/23/2014 12:38:29 AM    

Could the example be updated to 13.2.6?

Added By: Dennis (DevExpress Support) at: 1/23/2014 12:41:45 AM    

Guys, please refer to my answer in Q554368 (there you can find an updated version + a link to a hot fix build).

Added By: Kanapol W. at: 1/29/2014 7:58:02 AM    

Right now, I have upgrade to v2013 vol 2.5
I use the most update code in "v2013 vol 1.4- v2013 vol1.9" . It get the error.
Would you please update this example to work with the most update version?

Added By: Dennis (DevExpress Support) at: 1/29/2014 8:01:21 AM    

@Kanapol: This example will be updated once the version 13.2.7 is out (in a week or so). In the meantime, please check out my previous comment for a solution. Thanks.

Added By: Tony Tadros at: 12/23/2014 2:35:17 AM    

Hello Devexpress ,

i have a need to use this module with a small change
i want to have 2 types of variants System,UserDefined for the system ones it should prevent users doing any changes on layout
or to discard changes after user closes current view

if i extended the IModelVariant with the property Type {System,User Defined}how to use this property to after

Thanks & Regards
Tony

Added By: Dennis (DevExpress Support) at: 12/23/2014 8:45:51 AM    

@Tony: You can update the availability of the 'editViewVariantItem' and 'removeViewVariantItem' ChoiceActionItem objects of the Action based on your variant type information via the ChoiceActionItem.Active property:

 

This update can be done from within the UpdateUserViewVariantsAction method or on other events as you prefer.
As for discarding changes to a View, handle the View.ModelSaving event and set the Cancel parameter to True depending on your conditions. While we do not have a ready sample or guidelines for this particular customization, do not hesitate to contact us if you experience any difficulties using the XAF API I suggested above.

Added By: PTLab at: 6/29/2015 3:45:52 AM    

Dennis, it's very interesting example, thank you. I tested this solution in my project, that have implementation of storing user model in database. All One user modifications stored in database, but Other user have all One's modifications after login. Whats wrong, and how realy separate changes?

Added By: Dennis (DevExpress Support) at: 6/29/2015 6:31:30 AM    

@PTLab: Thanks for your feedback. To process your recent post more efficiently, I created a separate ticket on your behalf: T261243: E2813 and model differences stored in the database. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.


How to build a simple data analysis application using the XtraPivotGrid

$
0
0

This solution is created to illustrate the steps described in the Building a data analysis application using the XtraPivotGrid tutorial series.


The solution consists of the following projects:

XtraPivotGridTutorial.Step1 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 1 - Binding the PivotGrid to dataarticle

XtraPivotGridTutorial.Step2 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 2 - Configuring pivot fields article

XtraPivotGridTutorial.Step3 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 3 - Configuring the Customization Formarticle

XtraPivotGridTutorial.Step4 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 4 - Adding unbound fields article

XtraPivotGridTutorial.Step5 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 5 - Integrating the ChartControl article

XtraPivotGridTutorial.Step6 - The resulting project for the Building a data analysis application using the XtraPivotGrid. Part 6 - Printing and exporting data article

Question Comments

Added By: samnang sang at: 6/29/2015 6:49:48 PM    

I can not start directly with this. A Project With An Out Put of Class Library

Added By: Alex (DevExpress Support) at: 6/30/2015 12:07:52 AM    

To solve this issue, set an appropriate project (e.g., XtraPivotGridTutorial.Step1) as a startup project for a solution by right-clicking the project in Visual Studio's Solution Explorer and selecting the Set as StartUp Project option.

DateEdit - How to remove increment and decrement year buttons in Classic mode

$
0
0
This example illustrates how to remove decrement and increment year in DateEdit when the CalendarStyle property is set to Classic

How to: Hide the 'Protected Content' Rows in List Views

MVC DocumentViewer - How to create a custom CheckedComboBox parameter editor with the "Select All" functionality for a report

$
0
0

This example demonstrates how to create a custom CheckedComboBox parameter editor with the "Select All" functionality for a report that is previewed in the MVC DocumentViewer extension. 

The report's built-in multi-select parameter functionality can use only the TokenBox editor. So, this approach will be helpful if you wish to use the CheckedComboBox editor with the "Select All" functionality.

The approach demonstrated in the  Data Editors - Editor Types - Dropdown Edit online demo is used to create a CheckedComboBox editor. The only difference is that the CheckedListWindowTemplate class that implements the ITemplate interface is used to set the DropdownWindowTemplate content.

Important Note: The new WebDocumentViewer extension uses the CheckedComboBox editor for multi-select parameters out of the box.

ASPxGridView - How to export a colored grid when the Data Aware export mode is used

$
0
0

In v2014 vol 2, we introduced the Excel Data Aware Export feature into our grid. While this feature significantly improves the export capabilities (see the New Excel Data Export Engine blog post), it also has some limitations. Most of them are described in the T186064: ASPxGridView / MVC GridView Extension - Excel Data Aware Export FAQ article.
One of them is that the ASPxGridViewExporter.RenderBrick event is not raised when the data-aware export is used. Commonly, this event is used for customizing the cell appearance in resulted documents (a back color, fonts, a format, etc.). While this event is not available, it is still possible to accomplish this task. The XlsxExportOptionsEx object provides the CustomizeCell event that can be used for customizing cells in the exported document:

[C#]
varexportOptions=newXlsxExportOptionsEx();exportOptions.CustomizeCell+=exportOptions_CustomizeCell;ASPxGridViewExporter1.WriteXlsxToResponse(exportOptions);...voidexportOptions_CustomizeCell(DevExpress.Export.CustomizeCellEventArgsea){if(ea.ColumnFieldName!="UnitsOnOrder")return;if(Convert.ToInt32(ea.Value)== 0)ea.Formatting.BackColor=Color.Salmon;elseea.Formatting.BackColor=Color.LightGray;ea.Handled=true;}
[VB.NET]
Dim exportOptions = New XlsxExportOptionsEx()AddHandler exportOptions.CustomizeCell, AddressOf exportOptions_CustomizeCell ASPxGridViewExporter1.WriteXlsxToResponse(exportOptions) ...PrivateSub exportOptions_CustomizeCell(ByVal ea As DevExpress.Export.CustomizeCellEventArgs)If ea.ColumnFieldName <> "UnitsOnOrder"ThenReturnEndIfIf Convert.ToInt32(ea.Value) = 0 Then ea.Formatting.BackColor = Color.SalmonElse ea.Formatting.BackColor = Color.LightGrayEndIf ea.Handled = TrueEndSub

This example illustrates a sample scenario with exporting a colored grid when the Data Aware export mode is used.

Viewing all 7205 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>