Hi,
I'd like to get the name of the column who is the column in my filter expression. I persist the filter expression and want to set the filter expression and the selected filter function back, if the user comes back to the page. How can I achieve this?
Regards,
Adi
I'd like to get the name of the column who is the column in my filter expression. I persist the filter expression and want to set the filter expression and the selected filter function back, if the user comes back to the page. How can I achieve this?
Regards,
Adi
10 Answers, 1 is accepted
0
Hi Adi,
I think that the following online demo of RadGrid for ASP.NET AJAX illustrates how to achieve your goal:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx
Review the implementation in it along with the help article linked under its Description tab for further details.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I think that the following online demo of RadGrid for ASP.NET AJAX illustrates how to achieve your goal:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx
Review the implementation in it along with the help article linked under its Description tab for further details.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
adi
Top achievements
Rank 1
answered on 10 Mar 2010, 04:03 PM
Hi Sebastian,
this is, what I'm looking for. But the sample generates an exception at line:
Cannot convert to GridFilteringItem.
I've checked the array like this:
but Length is always 0. What is the problem?
I have some hidden columns in the grid and some columns that are set to AllowFiltering="False".
Regards,
Adi
this is, what I'm looking for. But the sample generates an exception at line:
| GridFilteringItem filterItem = (GridFilteringItem)gridInstance.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; |
Cannot convert to GridFilteringItem.
I've checked the array like this:
| if (gridInstance.MasterTableView.GetItems(GridItemType.FilteringItem).Length > 0) |
I have some hidden columns in the grid and some columns that are set to AllowFiltering="False".
Regards,
Adi
0
Hi Adi,
Do you have the property AllowFilteringByColumn set to true for your grid instance? This is a requirement in order to render the GridFilteringItem and access it.
Additional information about how to operate with the FilterExpression of the control manually you can gather from here.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Do you have the property AllowFilteringByColumn set to true for your grid instance? This is a requirement in order to render the GridFilteringItem and access it.
Additional information about how to operate with the FilterExpression of the control manually you can gather from here.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
adi
Top achievements
Rank 1
answered on 10 Mar 2010, 06:13 PM
Hi Sebastian,
I'vew found the issue. I don't use a button event. I use a page event, instead. And so, I had the wrong. Now this works. But I've found an other problem with the sample code.
What should the line do?
This ArrayList is just initialized with a capacity of n columns. But can't be iterated, because there is nothing load on it.
So this makes no sense.
Regards,
Adi
I'vew found the issue. I don't use a button event. I use a page event, instead. And so, I had the wrong. Now this works. But I've found an other problem with the sample code.
What should the line do?
| ArrayList allLoadColumns = new ArrayList(columnsLength); |
So this makes no sense.
| foreach (GridColumn column in allLoadColumns) |
Regards,
Adi
0
Hi Adi,
The ranges added right after the code line you specified should generate the column members in the allColumns array featured on the online example:
Let me know if I am missing something obvious.
Regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The ranges added right after the code line you specified should generate the column members in the allColumns array featured on the online example:
//Save columns order int columnsLength = gridInstance.MasterTableView.Columns.Count + gridInstance.MasterTableView.AutoGeneratedColumns.Length; Pair[] columnOrder = new Pair[columnsLength]; ArrayList allColumns = new ArrayList(columnsLength); allColumns.AddRange(gridInstance.MasterTableView.Columns); allColumns.AddRange(gridInstance.MasterTableView.AutoGeneratedColumns); Let me know if I am missing something obvious.
Regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
adi
Top achievements
Rank 1
answered on 11 Mar 2010, 10:42 AM
Hi Sebastian,
you're right. SaveSettings works. But what about the LoadSettings?
Regards,
Adi
you're right. SaveSettings works. But what about the LoadSettings?
| //Load visible/displayed columns and their current filter values/current filter functions |
| ArrayList visibleCols = (ArrayList)gridSettings[4]; |
| ArrayList displayedColumns = (ArrayList)gridSettings[5]; |
| Pair[] columnFilter = (Pair[])gridSettings[6]; |
| int a = 0; |
| ArrayList allLoadColumns = new ArrayList(columnsLength); |
| GridFilteringItem filterItem = (GridFilteringItem)gridInstance.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; |
| foreach (GridColumn column in allLoadColumns) |
| { |
| column.CurrentFilterFunction = (GridKnownFunction)columnFilter[a].First; |
| column.CurrentFilterValue = (string)columnFilter[a].Second; |
| (filterItem[column.UniqueName].Controls[2] as TextBox).Text = (string)columnFilter[a].Second; |
| column.Visible = (bool)visibleCols[a]; |
| column.Display = (bool)displayedColumns[a]; |
| a++; |
| } |
Regards,
Adi
0
Hi Adi,
The same ranges are added in the LoadSettings method:
//Load columns order
int columnsLength = this.gridInstance.MasterTableView.Columns.Count +
this.gridInstance.MasterTableView.AutoGeneratedColumns.Length;
Pair[] columnOrder = (Pair[])gridSettings[2];
if (columnsLength == columnOrder.Length)
{
ArrayList allColumns = new ArrayList(columnsLength);
allColumns.AddRange(this.gridInstance.MasterTableView.Columns);
allColumns.AddRange(this.gridInstance.MasterTableView.AutoGeneratedColumns);
int i = 0;
foreach (GridColumn column in allColumns)
{
column.OrderIndex = (int)columnOrder[i].First;
column.HeaderStyle.Width = (Unit)columnOrder[i].Second;
i++;
}
}
Let me know if I am leaving something out.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The same ranges are added in the LoadSettings method:
//Load columns order
int columnsLength = this.gridInstance.MasterTableView.Columns.Count +
this.gridInstance.MasterTableView.AutoGeneratedColumns.Length;
Pair[] columnOrder = (Pair[])gridSettings[2];
if (columnsLength == columnOrder.Length)
{
ArrayList allColumns = new ArrayList(columnsLength);
allColumns.AddRange(this.gridInstance.MasterTableView.Columns);
allColumns.AddRange(this.gridInstance.MasterTableView.AutoGeneratedColumns);
int i = 0;
foreach (GridColumn column in allColumns)
{
column.OrderIndex = (int)columnOrder[i].First;
column.HeaderStyle.Width = (Unit)columnOrder[i].Second;
i++;
}
}
Let me know if I am leaving something out.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
adi
Top achievements
Rank 1
answered on 11 Mar 2010, 11:04 AM
Hi Sebastian,
you reflect to allColumns. But what about allLoadColumns?
Regards,
Adi
you reflect to allColumns. But what about allLoadColumns?
Regards,
Adi
0
Accepted
Hello Adi,
Indeed there was a discrepancy in the code concerning the allLoadColumns ArrayList - thank you for spotting it and notifying us about that. The implementation is already updated online and you can refer to the modified code in the example for more details. I updated your Telerik points for the involvement.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Indeed there was a discrepancy in the code concerning the allLoadColumns ArrayList - thank you for spotting it and notifying us about that. The implementation is already updated online and you can refer to the modified code in the example for more details. I updated your Telerik points for the involvement.
Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
adi
Top achievements
Rank 1
answered on 11 Mar 2010, 06:50 PM
Hello Sebastian,
this works fine. And if you have some hidden columns in your RadGrid, you have to check this, too.
Regards,
Adi
this works fine. And if you have some hidden columns in your RadGrid, you have to check this, too.
| if (filterItem[column.UniqueName].Controls.Count > 0) |
| { |
| ((TextBox)filterItem[column.UniqueName].Controls[0]).Text = (string)columnFilter[a].Second; |
| } |
Regards,
Adi