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

ASPxGridView - Keep detail grid selection in DataItemTemplate checkbox on paging main grid


Implement the "Select All" CheckBox editor in ASPxGridView's row in Batch Edit Mode

$
0
0

This example illustrates how to change editors based on other editors in a current row when ASPxGridView in Batch Edit Mode.
If an end-user checks the check box in ASPxGridView's "All" column, other check boxes in this row will be set checked. If an end-user unchecks the check box in the ASPxGridView's "All" column, other check boxes in this row will become unchecked. If all check boxes in ASPxGridView's row are checked, the check box in ASPxGridView's "All" columns will be set checked. If at least one of check boxes in ASPxGridView's row is checked, the check box in ASPxGridView's "All" column  will become grayed.

To allow the "All" check boxes grayed state, use the CheckBoxProperties.AllowGrayed,   CheckBoxProperties.ValueType, CheckBoxProperties.ValueGrayed  properties.

To implement the described scenario in common, handle the ASPxClientGridView.BatchEditStartEditing and CheckEditClientSideEvents.CheckedChanged events.

Note that unbound columns are used because the example database does not contain appropriate data to illustrate this scenario. This approach can be also easily applied to bound columns.

Create a custom ASPxGridView filter insensitive to the number of spaces and punctuation

$
0
0

This example shows how to apply a custom filter to the text in the Auto Filter Row editor.

When the ASPxGridView.ProcessColumnAutoFilter event is raised before the filter criterion is applied, we parse the ASPxGridView.FilterExpression and take only a custom filter for the current column using the FindAndRemoveCustomOperator function.

In the MergeCriterias function, we make a custom criterion and then apply it.

When the AutoFilterCellEditorInitialize event is raised, we get a custom filter for a certain column from the FindAndRemoveCustomOperator function and pass it to the Auto Filter Row editor.

See also:
How to register a custom filter function and use it in ASPxGridView

Create ASPxGridView with a custom pager and the "Selecting a page size" feature at runtime

Switch ASPxGridView between Linq and Entity server mode data sources at runtime

$
0
0

This example demonstrates how to use the same grid to view different data sources. The grid's column is autogenerated.

Please note that the ViewStateMode property should be disabled to allow the grid to work properly.

ASPxGridView - Change group rows' color and set it for a child row with the expanded group

$
0
0

This example shows how to change group row background color based on row level in an ASPxGridView. When a group row is expanded, each child row maintains the same color for the cell that has the same level as the group row.

ASPxGridView - Implement an advanced tooltip for command buttons using ASPxHint

Display ASPxGridView's visible data in WebChartControl without whole page refreshing


ASPxGridView - Prevent focusing the first row on the first page load

$
0
0

To do this, handle the ASPxGridView's DataBound event handler and set the FocusedRowIndex to -1.

ASPxGridView - Show a modal popup using the control in DetailRowTemplateContainer

$
0
0

This sample illustrates how to show the a modal popup from the detail grid and populate a combobox within this popup control.

ASPxGridViewExporter - Export each grid page to a separate sheet in the XLSX file

ASPxRichEdit - How to implement the Format Painter functionality

$
0
0

Currently, ASPxRichEdit doesn't provide the Format Painter feature out of the box. This example illustrates a possible solution to implement this functionality in a custom way by using custom ribbon buttons and the ASPxRichEdit's client-side API.

For this purpose, handle the editor's client-side CustomCommandExecuted event to check if a custom ribbon item is clicked, and get the font and paragraph formatting applied to the currently selected content via the changeFontFormatting.getState()changeParagraphFormatting.getState() commands.
To achieve the behavior similar to that the MS Word Format Painter's provides, the ASPxRichEdit selection is changed programmatically to select only the selected text's first symbol before calling corresponding commands in order to get its formatting as the formatting of the selected interval. After retrieving formatting information for this symbol, the control's selection is restored to its original state.
After that, the saved formatting can be applied to the new selected content on a ribbon item click via the changeFontFormatting and changeParagraphFormatting commands.

Accessibility: How to provide a screen reader with custom messages

$
0
0

This example illustrates how to provide a custom message to an Assistive Technology (for example, Screen Reader). The main idea of this approach is to add a special helper element to the page, set your custom message as its "aria-label" attribute value, and then focus this element. This will force your screen reader or another assistive technology to read the message.


Here, the task is implemented for a basic ASP.NET ListBox and DevExtreme dxDataGrid widget. The grid displays data depending on the ListBox selection. When the selection is changed, the data in the linked grid is filtered  and we send a custom information message. A similar scenario is illustrated in the Accessibility - Linked Controls online demo, but instead of a custom AccessibilityHelper implementation, this demo uses our client API: ASPxClientUtils.SendMessageToAssistiveTechnology.

Main implementation steps:
1. Add a special assistive element to the page using the AccessibilityHelper constructor (its implementation is in the AccessibilityHelper.js file):

[JavaScript]
var accessibilityHelper = new AccessibilityHelper();

 2. Save the old state for a control or page, when necessary. In this example, the ListBox' onchange event is used for this purpose:

[JavaScript]
listBox.change(function(){... oldClientCount = grid.totalCount(); countriesChanged = true;...});

 You can handle several events for different controls in your real-life scenario.

3. Handle the event that occurs when changes are complete. Here, the dxDataGrid.onContentReady event is used. Check if there is the difference between the previous and current states, and to pass the corresponding message text as an argument to the AccessibilityHelper.SendMessageToAssistiveTechnology method:

[JavaScript]
function OnContentReady(){...var newCount = grid.totalCount();var changesInfo = GetChangesInfo(newCount); accessibilityHelper.SendMessageToAssistiveTechnology(changesInfo);}

 The complete implementation of the AccessibilityHelper.SendMessageToAssistiveTechnology method is in the AccessibilityHelper.js file.


To test the example, run it in browser and enable your assistive technology. You can use NVDA or JAWS screen readers for testing purposes. Change the "Countries" list box selection: the assistive software or device should inform you about the changes in the "Clients" grid with a corresponding message.

See Also:
Accessibility - How To: Provide a Screen Reader with Information About Changes on a Page

Optimistic concurrency in ASPxGridView without an additional "row version" column

$
0
0

This approach does not require adding a row's version column to the underlying table. The main idea is to generate hash strings for rows on every server action. Then, you need to generate hash for the currently edited/deleted record and compare it with the stored string in the RowUpdating/RowDeleting events handlers.

Pros:

- You don't need to modify your database;

Cons:

- Hash strings should be calculated on every round-trip to server. However, this operation is rather quick, so it should not cause problems with performance. You can also increase hash generating speed by using fast hashing algorithms, like MurMurHash3 Algorithm.

ASPxCardView - Implementing CRUD functionality similarly to FormView and DetailsView

$
0
0

This example illustrates how to implement CRUD (create, read, update, delete) operations in the manner supported by FormView and DetailsView. In other words, records should be edited one by one. The easiest way to accomplish this task is to use ASPxCardView. This control supports data binding and data editing operations out of the box. It also provides the form-like layout and allows you to generate required editors with ease. 

Click the "Show Implementation Details" button below to see a step-by-step guide on how to implement this scenario. 


Accent-insensitive filtering in ASPxGridView with a Server Mode data source

$
0
0

When ASPxGridView is bound to a server mode data source, all data operations are performed on the database server: Binding to Large Data (Database Server Mode)?. Thus, results depend on database settings. For instance, filtering data with diacritic signs depends on the default collation of your data server:
[CodeProject.com] Configuring SQL Server Accent-Insensitivity
[Stackoverflow.com] Questions about accent insensitivity in SQL Server (Latin1_General_CI_AS)?

In other words, the first solution to achieve accent-insensitive filtering when the grid is bound to the server mode datasource is to change collation on the server. 
Another solution is to create a custom filter operator by implementing ICustomFunctionOperator and  ICustomFunctionOperatorFormattable interfaces and modify a filtering request to the database in the ICustomFunctionOperatorFormattable.Format method:

[C#]
stringICustomFunctionOperatorFormattable.Format(TypeproviderType,paramsString[]operands){varoperand=string.Format("N'%{0}%'",operands[0].Split('\'')[1]);returnstring.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ",operands[1],operand);}
[VB.NET]
PrivateFunction ICustomFunctionOperatorFormattable_Format(ByVal providerType As Type, ParamArrayByVal operands() AsString) AsStringImplements ICustomFunctionOperatorFormattable.FormatDim operand = String.Format("N'%{0}%'", operands(0).Split("'"c)(1))ReturnString.Format("{0} COLLATE SQL_Latin1_General_CP1_CI_AI LIKE {1} ", operands(1), operand)EndFunction

 

In this case, the accent-insensitive collation is applied only for filtering. Note that this approach is not supported by LINQ-based ORMs.

This example demonstrates how to implement accent-insensitive filtering in Auto Filter Row when ASPxGridView is bound to XpoDataSource with Server Mode enabled. To test the example, download the solution to your local machine.

See Also:
How to make the Grid's filter to be a case- and accent-insensitive in Server Mode
E4836: How to create a custom ASPxGridView's filter insensitive to the number of spaces and punctuation

ASPxGridView - Show a separate detail grid when changing a master grid’s focused row using keyboard

$
0
0

This example demonstrates how to implement a master-detail scenario with two separate grids. The KeyboardSupport property allows changing the master grid's focused row by pressing navigation keys. The detail grid updates information when the master grid's focused row is changed.


How to dynamically generate a report and bind it to a collection of objects

$
0
0

This example illustrates how to create a report in code.

The following steps are essential to create a report layout:

1. Create a report instance and bind it to data.

2. Add required bands to the report.

3. Add required controls to the created bands and provide data to them.

After the report layout is complete, you can generate the report document and display it in a Print Preview.

See also:
How to dynamically generate a master-detail report in a WinForms application
How to dynamically generate a report and bind it to a DataSet in a WinForms application
How to create a report dynamically

How to catch the moment when a user changes a focused cell

$
0
0

This example demonstrates how to catch the moment when an end-user changes the focused cell

How to implement IDataDictionary/IDisplayNameProvider for a Business Object

$
0
0

Description:
I'm using the System.Collections.Generic.List collection as a report's datasource.
I set it like this:

[C#]
List<MyObject>list=newList<MyObject>();report.Datasource=list;

How do I change/specify the names in the field list with my desired display name?

Solution:
You should implement the IDisplayNameProvider(IDataDictionaryin versions prior to v2011 vol 2) interface over your collection object. The IDisplayNameProvider interface has two methods that will help to change the display name of the required field. In the attached sample I show how you can change the display name, by using the custom attributes implemented over the Business Objects properties.

See also: How to provide custom names for the Field List data items.

Viewing all 7205 articles
Browse latest View live


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