iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi
I have still a problem with sorting in UXGridView. I want to sort only by a specific column (no grouping). That is why I added a SortDescriptor in the constructor of ViewModel. This has been discussed in this thread. Now I have found that always the first LoadData command twice is running! Have a look on attached picture. Can you explain to why this is so?
Why can I not define SortDescriptor in XAML? Would this change something?
<Intersoft:UXGridView.SortDescriptors> <Intersoft: </Intersoft:UXGridView.SortDescriptors>
Regards
Michael
Data sorting can be handled in either client or server side.
Client data operation means that the data operation such as sorting is executed in client against the data source provided to UXGridView.
Server data operation means that the data operation such as sorting is processed in server rather than in client. When this mode is selected, UXGridView will not attempt to perform the data operation on the given data source. Instead, it will store and distribute the query information to the SortDescriptors property. When the collection changes, the QueryChanged event of the associated QueryDescriptor will be raised. This allows you to streamline the query processing in a centralized function, which is one of the strong benefits of QueryDescriptor.
To implement a predefined sorting, you can specify the SortDescriptions (in xaml code) or SortDescriptors property (in view model). The SortDescriptions is used when the control is configured with sorting client data operation, while the SortDescriptors is used for server data operation.
The “query running twice” only happens on the server data operation (please check that by using the SortDescriptions approach, the query only run one times). Each time the collection change, the OnQueryChange event of the associated QueryDescriptor is raised. The first query is used to load the data and the next one is sort the data at the server.
Hope this helps.
In order to implement a predefined sorting in XAML, please try to use following snippet code.
<Intersoft:UXGridView.SortDescriptions> <ComponentModel:SortDescription PropertyName="Country" Direction="Descending"/> </Intersoft:UXGridView.SortDescriptions>
The “ComponentModel” namespace needs to be defined in the XAML using:
xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=System.Windows"
Adding SortDescriptor in the constructor of ViewModel can be achieved by using following code.
this.QueryDescriptor.SortDescriptors.Add(new SortDescriptor() { PropertyName = "Country", Direction = ListSortDirection.Descending });
When using this technique, the QueryDescriptor instance is set with SortDescriptors collection which provides the required information for data query purpose. The SortDescriptors collection consist of a single SortDescriptor where PropertyName is set to “Country” and Direction is set to “Descending”.
Defining SortDescriptor in XAML as shown in the following code is not going to work because the SortDescriptor that defined in XAML unable to set the QueryDescriptor in the ViewModel.
<Intersoft:UXGridView.SortDescriptors> <Intersoft:SortDescriptor PropertyName="Country" Direction="Descending" /> </Intersoft:UXGridView.SortDescriptors>
I need to discuss about why the “LoadData” run twice with the UXGridView development team does. I’ll update to you as soon as I received any news from the team.
Hi Yudi
Sorting in xaml does not work! I have tested on Products Page (Client UI Sample). I have added the SortDescriptiors and commented out the GroupDescriptor as follow:
<!--<Intersoft:UXGridView.GroupDescriptors> <Intersoft:UXGridViewGroupDescriptor PropertyName="CategoryID"/> </Intersoft:UXGridView.GroupDescriptors>--> <Intersoft:UXGridView.SortDescriptions> <ComponentModel:SortDescription PropertyName="CategoryID" Direction="Ascending"/> </Intersoft:UXGridView.SortDescriptions>
In query orderby is not added!
Adding SortDescriptor in the constructor works fine (exept run twice).
I tested the “SortDescriptions” (sorting in xaml) by creating a project using the “Intersoft ClientUI MVVM Data Application (WCF RIA SP1)” and modify the Products.xaml page. The modified version of Products.xaml is enclosed as attachment.
I also tried the “SortDescriptions” in Customers.xaml. First, I follow every step in “Walkthrough: Bind UXGridView to WCF RIA Services using MVVM Pattern” article that available in the ClientUI’s documentation and add the “SortDescriptions” as shown in my previous post (sorting “Country” in descending direction).
Should you have any difficulties apply sorting in xaml by using the same method, please let me know. I’d be glad to provide you with complete project if necessary.
Thank you and have a nice day.
Thanks for sample.
The only difference was that I had not deleted the properties SortDescriptors, PageDescriptor, FilterDescriptors at the UXGridView. Now it works, but without paging, and filtering!
<Intersoft:UXGridView Intersoft:DockPanel.IsFillElement="True" AutoGenerateColumns="true" QueryOperation="Server" GroupFootersVisibility="Visible" GroupByBoxVisibility="Visible" RowHeaderVisibility="Visible" CanUserAddRows="True" CanUserDeleteRows="True" CanUserEditRows="True" CanUserPage="True" PageSize="20" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ItemsSource="{Binding Path=Items}" IsBusy="{Binding IsBusy, Mode=TwoWay}" IsRefreshed="{Binding IsRefreshed, Mode=TwoWay}" NewItem="{Binding NewItem, Mode=TwoWay}" ValidateRowCommand="{Binding ValidateRowCommand}" InsertRowCommand="{Binding InsertRowCommand}" DeleteRowCommand="{Binding DeleteRowCommand}" PrepareNewRowCommand="{Binding PrepareNewRowCommand}" UpdateCellCommand="{Binding UpdateCellCommand}" UpdateRowCommand="{Binding UpdateRowCommand}" SaveChangesCommand="{Binding SaveChangesCommand}" RejectRowCommand="{Binding RejectRowCommand}" RejectChangesCommand="{Binding RejectChangesCommand}" HasChanges="{Binding HasChanges}" AutoEditOperation="{Binding AutoEditOperation}"> <!--SortDescriptors="{Binding QueryDescriptor.SortDescriptors, Mode=TwoWay}" PageDescriptor="{Binding QueryDescriptor.PageDescriptor}" FilterDescriptors="{Binding QueryDescriptor.FilterDescriptors, Mode=TwoWay}"-->
Perhaps it is easier to define the sorting in the constructor. Just yet, the question is why the query twice running.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname