Hi There,
Whats the best approach to implement sorting in WebDatagrid ,The grid is bind through code behind and also its rebinds based on user selection.
And also want to have sorting default to a specific column on initial load.(Tried with adding the default column to ".Behaviors.Sorting.SortedColumns.Add" on initial load, not worked.)
Here is the Grid definition
Behaviour->Sorting->Enabled =True
EnableAjax=True,
EnableDataViewState=true,
ColumnSorted handled to rebind the data,but getting Server Not responding error.
If I set EnableAjax=False the ColumnSorted event works without error and sorts grid ,but the whole page refreshes and but default sorting fails.
I want to avoid the whole page refresh.
Thanks ...
Hello,
Thank you for posting in the Infragistics community ! Please find answers to your questions below:
1) Basically when you have EnableDataViewState = true you do not need to rebind the grid, as the grid loads its data from the DataViewState.
2) And also want to have sorting default to a specific column on initial load.(Tried with adding the default column to ".Behaviors.Sorting.SortedColumns.Add" on initial load, not worked.)
Do you have AutoGenerateColumns set to true ? IF this is the case then the grid columns collection is empty and you are actually adding null to the SortedColumns collections. Please see if this is the issue.
In every case I am attaching a small sample app that demonstrates how the grid is loaded with one of its columns sorted initially. Also, I have set EnableDataViewState = true, so I grid is bound at initial load only:
if (!IsPostBack) { WebDataGrid1.ClearDataSource(); WebDataGrid1.DataSource = GetDataSource(); }
Please review it and let me know if you have further questions on the matter, I will be glad to help.
Hi ,
I already have set up of AutoGenerateColumns=False as i defined all columns in markup itself.
I tried with your sample and that also not working attached the screen shots after sorting from your sample.
i am using Infragistics Version 14.1
<add assembly="Infragistics4.Web.v14.1, Version=14.1.20141.1015, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
Thanks & Regards
Sorry I missed to explain the following:
When EnableDataViewState = true the grid needs to be supplied with its original data, e.g to bind on every postback. Failing to do this (as in my sample) results that the data stays in the view state as it went in.
So I suggest that you simpy provide the data on each postback:
if (Session["data"] == null)
{
Session["data"] = GetDataSource();
}
WebDataGrid1.DataSource = (DataTable)Session["data"];
Please let me know if you have further questions on the matter.
Hi
When i implemented the same changes to my application its still giving me Server Not responding error when i enable Ajax but in your sample code its works.I am clueless here.
Hi,
Thank you for your feedback.
Please refer to this resource which I believe you will find helpful regarding the use of EnableDataViewState, as well as EnableAjax and EnableViewState:
http://es.infragistics.com/community/forums/t/65461.aspx
Please try to provide a working sample reproducing the "server not responding" error, and I will be glad to investigate it and suggest a resolution for you.
I'm just following up to see if you need any further assistance with this issue. If so please let me know.