Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
DataTable is sorted but data in WHDG is not sorted
posted

I have a problem with sorting in WHDG. I'm binding DataTable that are sorted by Department, Workplace and EmployeeName. In WDHG are data grouped by Department and Workplace (data are sorted correctly). But problem is that employee name are not sorted. I'm not using any sorting behavior because, I don't want to enable sorting to customer.

  • 49378
    posted

    Hi los_milanos,

    In order to ensure that your data is sorted by some criteria, I would suggest that you use client-side code to sort the child grid of each expanded parent row. That would require having sorting enabled, but sorting itself can be cancelled using the ColumnSorting client-side event:


    function WebHierarchicalDataGrid1_Sorting_ColumnSorting(sender, eventArgs) {
       
    //cancels user sorting
       
    eventArgs.set_cancel(true);
    }

     

     

    function

     

     

     

     

     

    //when a parent row is epxanded, sort the child by its first column, i.e. ProductName
    eventArgs.get_row().get_rowIslands()[0].get_behaviors().get_sorting().sortColumn(eventArgs.get_row().get_rowIslands()[0].get_columns().get_column(1), 1);
    }

    WebHierarchicalDataGrid1_ContainerGrid_RowExpanded(sender, eventArgs){

     

     

     

     

     

    I am attaching my test sample which uses the Northwind DB to illustrate this scenario.

    Please let me know if this helps.

    Best Regards,

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://ko.infragistics.com/support

     

    WHDGSortingonChildren.zip