I have an User control having UltraWebGrid in my application. I am applying GroupByColumn on the data for three levels:
like
UltraWebGrid1.Rows.Band.Columns.FromKey("COLUMN_NAME1").IsGroupByColumn = true;
UltraWebGrid1.Rows.Band.Columns.FromKey("COLUMN_NAME2").IsGroupByColumn = true;
UltraWebGrid1.Rows.Band.Columns.FromKey("COLUMN_NAME3").IsGroupByColumn = true;
after that I need to apply order by or sort the data before displaying on the web page page. I cannot use the UI for sorting data.
My data is already sorted as I used Order By in the select query.
The data is also coming sorted from database but after applying the "IsGroupByColumn" my data sorting is gone and I cannot find any way to sort the data before displaying in UI.
If anyone has faced this problem please share your solution if any.
Thanks.
Hi Ajay,
Thank you for posting in the community.
You can achieve sorting on page load using code, similar to the following:
UltraWebGrid1.Columns.FromKey("ColumnName").SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.Descending;
Please let me know if this helps.
Hello Ajay,
If you need any further assistance with the matter, please do not hesitate to ask.
Hi Nikolay,
Thanks for your reply.
I have following code snippet doing this task of applying group by and sorting
UltraWebGridReport1.DisplayLayout.GroupByBox.Hidden = true; UltraWebGridReport1.Rows.Band.Columns.FromKey("EMPLOYEE_NAME").IsGroupByColumn = true; UltraWebGridReport1.Rows.Band.ExpandAll(true); UltraWebGridReport1.Columns.FromKey("EMPLOYEE_DEPTNAME").SortIndicator = Infragistics.WebUI.UltraWebGrid.SortIndicator.Ascending;
Where one employee belongs to more than one department. say emp1 belongs to IT,HR,Finance,Management etc.
So When I fethches data from from DB I get, let's say 2 employees (emp1 and emp2) and their corresponding departements.
so if emp1 is having departments as IT, HR, Finance
and
emp2 is having departments as IT,HR,FInance, Management
then I will get total 7 rows from DB. My data from DB is order by on EMPLOYEE_NAME, EMPLOYEE_DEPTNAME
I apply this data to my UltreawebGrid and apply above mentioned group by and sorting.
Now when I am seeing the data on UI, I can see two different groups based on EMployeeName as there are two employees. Correct data is also showing for both groups but for each group data is NOT sorted based on EMPLOYEE_DEPTNAME.
Please let me know if you need any fuhter info.
I am in need of a urgent solution. please help.
You should also add the column to the SortedColumns collection:
UltraWebGrid1.Bands[0].SortedColumns.Add(UltraWebGrid1.Columns.FromKey("EMPLOYEE_DEPTNAME"), true)
Hope this helps.
This worked great. Thanks you very much for your help and support.
Cheer,
Ajay
I'm glad to hear that.
If you have any other questions, please feel free to contact me.
Thanks Nikolay.
As a matter of fact I have posted one more question entitled 'Apply border color to UltraWebGrid cells (Only left and right sides of the cell)'
If can see that also that will be awesome.
Cheers,
Ajay :)