This example demonstrates how to force the NavBarGroupControlContainer fill the entire area in the NavBarControl when the corresponding NavBarGroup is expanded.
Forcing the group control container to adjust its size according to the NavBar's empty area
Change the LookupEdit AutoSearchColumnIndex on click when the HeaderClickMode=Sorting
This example shows how to make the AutoSearch feature within the drop down window work, based on a clicked column when the Properties.HeaderClickMode property is set to Sorting
How to save a layout of LayoutControl together with its child controls
By default, if you save a layout of LayoutControl, settings of layout items are saved (Save and Restore Layout ). When you load the saved layout, layout items will be created with saved settings only if LayoutControl contains child controls, whose names exist in the saved layout. Otherwise, layout items will not be created.
This example illustrates how to save settings of the child controls, too. For this, we have created two extension methods: SaveLayoutExToXml and RestoreLayoutExFromXml. These methods allow you to save and load child controls' settings. It makes sense to use these methods if it is necessary to re-create child controls from the saved layout with the saved settings. If a child control with the same name exists in LayoutControl, it will be removed and replaced by a new one retrieved from the saved layout. This approach is based on using a custom XmlXtraSerializer class.
Question Comments
Added By: Ho-Jun Seo at: 9/4/2014 5:42:36 PM
I am using version 12.1.12. It only has SaveLayoutToXml() and RestoreLayoutFromXml(). So I cannot restore my layout with childs controls.
How can I use SaveLayoutExToXml() and RestoreLayoutExFromXml() methods?
Hello,
As I can see, you have created a separate How to use SaveLayoutExToXml() and RestoreLayoutExFromXml() methods? thread.
Since our support policy implies that every ticket is devoted to a separate issue, let's continue our discussion there.
Added By: Adam Ziegler at: 2/16/2018 9:47:53 AM Boy, it sure would be a lot more helpful if this article also included the code for the two methods below. As it stands, it isn't helpful at all.RiaInstantFeedbackDataSource - How to show included entity field data using a custom View
This example shows how to create a new custom View that will include data from two dependent data tables.
Let's assume you need to show the Orders table content in DXGrid using the RiaInstantFeedbackDataSource. The Order entity has the CustomerID field and you may wish to display information about order's customer within the grid. For example, show the customer's name from the Customers table along with the CustomerID.
The easiest way to accomplish this task is to create a new View in the database that will include data from both the Orders and Customer tables. This can be done on the server side using the following SQL script:
[SQL]CREATE VIEW [dbo].[CustomerOrders] AS SELECT OrderID, CompanyName, ContactName, OrderDate FROM Orders inner join Customers on Orders.CustomerID = Customers.CustomerID
Now, when the new View is ready, you'll need to create an ADO.Net Entity Data Model based on this custom view and create a Domain Service based on this model. The required steps are similar to those shown in the 'How to: Use DXGrid with RIA Services' help topic. The only difference is that it is necessary to choose the new custom View in the 'Choose Your Data Base Object' data model wizard's dialog rather than Orders table.
As a result, a model with the following diagram will be created:
An alternative approach is to use the extended data query and join data from two tables within the Domain Service GetCustomerOrders method. Please refer to the RiaInstantFeedbackDataSource - How to show included entity field data in DXGrid using the extended data query example to see this approach in action.
Question Comments
Added By: rasool jalali at: 5/19/2015 7:25:09 AM
Hi dear
I want to use RiaInstantFeedbackDataSource in my silverligt project but this not exist in xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
or DevExpress.Xpf.Core.ServerMode namespace.
Where is my mistake ?
Please help me
To get access to this class, add the DevExpress.Xpf.Core.v14.2.Extensions.dll assembly to the application References.
How to implement the Master-Details functionality with the ServerMode enabled
In the 2012 vol 1 version we implemented a Master-Detail feature, and now we provide it out of the box.
Linq queries are created for the Product and ProductModel tables from the AdventureWorks DB. This DB can be downloaded by the following link: AdventureWorks DB
1. Create a linq query for ProductModel table;
2. Assign this property to the LinqServerModeSource.QueryableSource property; 3. Create a filtered linq query for the nested grid Product table.
The solution is to implement a multi-binding converter. In this converter, pass
the RowHandle and ActiveView. In the Convert method, create a new query. In the query, filter the Product based on the ProductModelID property
value of the current row. Also, create a new LinqServerModeSource object for the detail view, and assign your new query to the
LinqServerModeSource.QueryableSource property.
How to select all column cells by clicking on the column header similar to Excel
To provide this functionality, handle the ready-to-use ColumnHeaderClick event. In the event handler, iterate through the grid's visible rows and invoke the SelectCell method for them.
Question Comments
Added By: Ryan Lucking at: 10/31/2017 7:20:35 AM This example uses an obsolete API.
'GridViewBase.BeginSelection()' is obsolete: 'Use the DataControlBase.BeginSelection method instead'
'GridViewBase.EndSelection()' is obsolete: 'Use the DataControlBase.EndSelection method instead'
Added By: Ivan (DevExpress Support) at: 11/1/2017 7:18:47 AM Hi Ryan,
Thank you for letting us know. I have updated this example to avoid using these obsolete methods and overriding the non-documented OnColumnHeaderClick method.
How to run data-intensive operations on in-memory data in a separate thread
In this demo, the DevExpress Grid Control for Silverlight operates in Instant Feedback data binding mode on in-memory data. All operations on data (e.g. sorting, groping, filtering, summary calculation, etc.) are performed asynchronously in a separate thread without UI freezing.
See also:
WPF Data Grid Control – PLINQ Data Support
Binding to In-Memory Data Using PLINQ
How to implement CRUD operations when WcfInstantFeedback and WcfServerMode sources are used
This example shows how to use WcfInstantFeedbackDataSource or WcfServerModeDataSource with DXGrid, and how to implement CRUD operations (e.g., add, remove, edit) in your application via special behavior.
The test sample requires the SQL Express service to be installed on your machine.
We have created the WCFServerModeCRUDBehavior and WCFInstantModeCRUDBehavior attached behaviors for GridControl. For instance:
[XAML]<dxg:GridControl><i:Interaction.Behaviors><crud:WCFServerModeCRUDBehavior...><crud:WCFServerModeCRUDBehavior.DataSource/><dxsm:LinqServerModeDataSource.../></crud:WCFServerModeCRUDBehavior.DataSource></crud:WCFServerModeCRUDBehavior></i:Interaction.Behaviors></dxg:GridControl>
The WCFServerModeCRUDBehavior and WCFInstantModeCRUDBehavior classes contain the NewRowForm and EditRowForm properties to provide the "Add Row" and "Edit Row" actions. With these properties, you can create the Add and Edit forms according to your requirements:
[XML]<DataTemplatex:Key="EditRecordTemplate"> <StackPanelMargin="8"MinWidth="200"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <TextBlockText="ID:"VerticalAlignment="Center"Grid.Row="0"Grid.Column="0"Margin="0,0,6,4"/> <dxe:TextEditx:Name="txtID"Grid.Row="0"Grid.Column="1"EditValue="{Binding Path=Id, Mode=TwoWay}"Margin="0,0,0,4"/> <TextBlockText="Name:"VerticalAlignment="Center"Grid.Row="1"Grid.Column="0"Margin="0,0,6,4"/> <dxe:TextEditx:Name="txtCompany"Grid.Row="1"Grid.Column="1"EditValue="{Binding Path=Name, Mode=TwoWay}"Margin="0,0,0,4"/> </Grid> </StackPanel></DataTemplate><crud:WCFServerModeCRUDBehaviorNewRowForm="{StaticResource ResourceKey=EditRecordTemplate}"EditRowForm="{StaticResource ResourceKey=EditRecordTemplate}"/>
This Behavior classes require the following information from your data model:
- EntityObjectType - the type of rows;
- DataServiceContext - an object of the DataServiceContext type;
- PropertiesList - the table columns' list;
- PrimaryKey - the primary key of the database table;
- DataSource - an object of the WcfInstantFeedbackDataSource or WcfServerModeDataSource type.
[XML]<dxg:GridControl><i:Interaction.Behaviors><crud:WCFInstantModeCRUDBehaviorEntityObjectType="{x:Type sr:Item}"DataSource="{Binding ElementName=wcfInstantSource}"DataServiceContext="{Binding DataSource.DataServiceContext, RelativeSource={RelativeSource Self}}"/></i:Interaction.Behaviors></dxg:GridControl>
[C#]helper.PropertiesList.Add("Id");helper.PropertiesList.Add("Name");
See the WcfInstantFeedbackDataSource and WcfServerModeDataSource classes to learn more about WcfInstantFeedbackDataSource and WcfServerModeDataSource .
Behavior class descendants support the following commands: NewRowCommand, RemoveRowCommand, EditRowCommand. You can bind your interaction controls with these commands with ease. For instance:
[XML]<crud:WCFServerModeCRUDBehaviorx:Name="helper"/><StackPanelGrid.Row="1"Orientation="Horizontal"HorizontalAlignment="Center"><ButtonHeight="22"Width="60"Command="{Binding Path=NewRowCommand, ElementName=helper}">Add</Button><ButtonHeight="22"Width="60"Command="{Binding Path=RemoveRowCommand, ElementName=helper}"Margin="6,0,6,0">Remove</Button><ButtonHeight="22"Width="60"Command="{Binding Path=EditRowCommand, ElementName=helper}">Edit</Button></StackPanel>
By default, the WCFServerModeCRUDBehavior and WCFInstantModeCRUDBehavior solutions support the following end-user interaction capabilities:
1. An end-user can edit selected row values by double-clicking on a grid row or by pressing the Enter key if the AllowKeyDownActions property is True.
2. An end-user can remove selected rows via the Delete key press if the AllowKeyDownActions property is True.
3. An end-user can add new rows, remove and edit them via the NewRowCommand, RemoveRowCommand, and EditRowCommand commands.
Question Comments
Added By: Claire N Streb at: 8/12/2012 9:03:43 AM
Just in case anyone else experiences this problem, I received this error when trying to attach the provided Database.mdf file to the SQL Server database: The database '[snip]\DATABASE.MDF' cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported. To fix it, I opened the model, generated the database from the model, added the database into SQL Server under a different name, excluded Database.mdf from the solution, added the newly created database to the solution, and changed the web.config file.
Added By: paul schwartzberg 1 at: 11/7/2016 12:23:29 PM Indeed it does it.But the above does it -- per row -- (on all columns), and per View.KeyDown event, in which the handler saves when
e.Key == Key.Enter
Would it be possible,
(1) per lost focus,
(2) only on columns made thus editable (not on the whole TableView)
(3) with editing multiple cells (once column at a time) - i am looking at this demo for that
https://www.devexpress.com/Support/Center/Question/Details/T222522
right now i am working on (1) ... ideas?
If you guys had a demo that compined these two together ...
https://www.devexpress.com/Support/Center/Question/Details/T222522
https://www.devexpress.com/Support/Center/Example/Details/E3866
Applied per column (to edit multiple cells in selected columns) it would be great...
Regards,
Paul
As you already have a separate ticket where you described your final goal in detail - T446275 - let's continue our discussion there. I will reply to you in that ticket.
Apply different styles to ASPxComboBox items using server and client-side functionally
This example demonstrates how to apply different styles to different elements of the ASPxComboBox.
To do so, you should handle the ASPxComboBox.DataBound event and manually modify the text of items whose style you need to change. Please note that ASPxComboBox must have at least one string column or have no columns at all.
In the first case, you should work with ASPxComboBoxItem.GetValue and ASPxComboBoxItem.SetValue methods and in the second one, with the ASPxComboBoxItem.Text property. In both cases, you should add
to the text of the target item and set ASPxComboBox.EncodeHtml property to false. If this property is true, html tags will be displayed like common text.[HTML]<spanclass="someClass">
Finally, on the client side, you should change styles of elements marked by a specific class.
Please see this example for more details.
Show an error message for a control in EditFormTemplateContainer using a separate editor
This sample illustrates how to show error message for the control in the EditFormTemplateContainer
ASPxComboBox - Add an item after data binding and perform custom client validation
This example shows how to insert an item into the ASPxComboBox ItemCollecton in code behind. The ComboBox is originally bound to an Access data source at design time. In addition, custom client-side validation is performed on the ComboBox every time the validation button is clicked. If the selected items is the first item in the ComboBox (the item that was added after data-bound) validation fails and a message is displayed.
Initialize adding a Detail Grid row automatically after a Master Grid row is created
This example demonstrates how to handle the OnRowInserted event to add rows to the Detail Grid after a Master Grid row has been created.
ASPxGridView - How to edit a hidden cell in a popup editor
The solution is based on ASPxPopupControl with required editors whose values are stored in the data source in the ASPxCallbackPanel.Callback event handler.
Feel free to write me back if you have further questions.
ASPxGridView- Inline Edit - Display a custom error message in an edited row on the client
To display error message in edited row when inline edit mode is used you can add an ASPxLabel in the ASPxGridView.HtmlRowCreated event, and then set the editor's text on the client side.
ASPxGridView - Сustomize GroupSummary/TotalSummary via GroupFooter/Footer templates
This example illustrates how to get Summary Item values and change the default Summary rendering. Average values are calculated against the "Vote" column and are visualized via the ASPxProgressBar in GroupFooterTemplate (against each group of rows) and FooterTemplate (against all the rows).
The "Tag" attribute is added for the summaries that are visualized via the ASPxProgressBar. This attribute contains a summary's identificator.
The progress bars that visualize the group summaries get their values via the GetGroupSummaryValue() function. GroupFooterCellTemplateContainer object is passed to this function as a parameter that contains information about a group index.
In the GetGroupSummaryValue() function, the ASPxGridView.GetGroupSummaryValue method is used to get the GroupSummary value. This method has the following parameters:
VisibleIndex - is accessible from GroupFooterCellTemplateContainer;
SummaryItem - can be found by the ASPxSummaryItem.Tag value.
The progress bar that visualizes the overall summary gets its value via the GetTotalSummaryValue() function. This function utilizes the ASPxGridView.GetTotalSummaryValue method to get the total summary.
To perform text formatting for all the progress bars, the ASPxProgressBar.CustomDisplayFormat property is used. The ASPxProgressBar.DisplayMode property value is set to "Custom".
How to sum values of bound and unbound columns and calculate a total value on the client side
This example shows how to sum values in two columns. One of them is bound to a data source column. The other one contains ASPxSpinEditor fields, in which any numeric value can be typed. Results are shown in the 'Total' column. Also, in the footer of this column, the total sum of all its values is displayed.
All calculations are performed on the client side. Calculated values aren't stored in the data source. If you want to save your changes, we suggest you review How to perform ASPxGridView instant updating using different editors in the DataItem template for details
Question Comments
Added By: Sureshma Reddy at: 4/25/2016 12:37:57 AM In this example I want to add Totalsummery for Count column and Unitprice.
where Unitprice is having empty values which is given manually.So finally I want to change Count and I will give Unitprice so that the resultwill calculated as Totalcount,Total Unitprice and Total.
where Totalcount,Total Unitprice and Total should be AspxSummeryItems.
How to accomplish this Task..??
Thanks in advance.
Added By: Artem (DevExpress Support) at: 4/25/2016 1:23:41 AM
Hello,
Thanks for contacting us. I've created a separate ticket on your behalf (T371394: How to calculate total values on the client side). It has been placed in our processing queue and will be answered shortly.
Calculate total values of bound/unbound columns with sorting and paging on the client
This example is implemented based on the "How to sum values of bound and unbound columns and calculate a total value on the client side" example and calculates total values on sorting, grouping, and paging.
ASPxGridView - Set EditForm's Update/Cancel button visibility depending on conditions
This example shows how to set the visibility of the ASPxGridView EditFormTemplate Update/Cancel buttons depending on particular conditions at runtime.
When an end-user clicks the Edit button, every even row displays the EditForm template with the Update button and every odd row – with the Cancel button.
Question Comments
Added By: Himanshu Sekhar Behera at: 11/5/2012 8:23:05 AM
Hello, i am just updating Discontinued checkbox but its not working....
This is for you kind information.
Thanks
ASPxGridView - Change visibility or disable context menu items based on selected row data
There are two general approaches: server-side and client-side. In both cases, firstly, it's necessary to create all of the menu items using the ASPxGridView.FillContextMenuItems event. After that, some of menu items can be made invisible or disabled depending on certain conditions.
Server-side solution.
Handle the ASPxGridView.ContextMenuItemVisibility event and use its e.SetVisible and e.SetEnabled methods to show/hide or enable/disable items respectively.
Note that these methods have overloaded versions that allow one to change visibility or enabled state for a specific row or a specific column.
It's very important to set the ASPxGridViewBehaviorSettings.ProcessSelectionChangedOnServer property value to true. In this case, each time a row is selected or unselected, a callback will be sent to the server and context menu items will be recalculated. If this property value is set to false, the context menu won't be updated after selecting or unselecting a row on the client side.
So, this approach requires callbacks to be sent to the server each time the end-user selects or unselects a row. This is why the server-side approach is less preferable than the client-side one.
Client-side solution.
Since the grid's data isn't available on the client side, to hide or disable rows depending on certain data, we need to analyze that data on the server side to determine whether or not a row must be made invisible or disabled and pass this information to the client side. A good way to achieve this is to create a List<bool> object that would contain required information and pass it to the client side as a custom JavaScript property.
Then handle the ASPxClientGridView.ContextMenu event and use the e.menu property to get the ASPxClientPopupMenu object that represents the context menu. After that, you can use the e.menu.GetItemByName method to get a menu item and then the SetEnabled and SetVisible methods to enable/disable or show/hide items respectively.
In the example, there are three items in the context menu. The first of them is always visible and enabled; the second is always enabled, but visible only for selected rows; and the third one is always visible, but enabled only for selected rows that have a corresponding "Discontinued" field value set to "true". There are two pages in the example that demonstrate both the client-side and the server-side approaches.
Question Comments
Added By: Steve Mol at: 6/19/2014 11:46:56 PM
For a hybrid approach, you can set the ASPxGridViewBehaviorSettings.ProcessSelectionChangedOnServer property value to false. Then, handle the event on the Client-side. If it is determined in the Client-side that the circumstances require the server to handle the event, set e.processOnServer to true. In this way, anything that can be handled on the Client-side will be and no callback will occur. But if the server is needed, the callback can be forced.
On the other hand, you can set the ASPxGridViewBehaviorSettings.ProcessSelectionChangedOnServer property value to true. The Client-side event will still be called, and you can set e.processOnServer to false to cancel the callback.
Either approach should reduce the callback occurrences to only what is required.
Implement the multi-row editing functionality with a multi-page grid bound dynamically
See Also:
ASPxGridView - Multi-Row Editing
How to implement the multi-row editing feature in the ASPxGridView
Custom client-side logic implementation in the grid with multi-row editing
How to store template control values when the ASPxTreeList has nodes collapsed - a similar scenario
How to perform ASPxGridView instant updating using different editors in the DataItem template