This is a migrated thread and some comments may be shown as answers.

Send Filter command client-side and maintaining client-side state

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
romulo~
Top achievements
Rank 1
romulo~ asked on 01 Oct 2015, 08:44 PM

Hello,

I'm using a RadGrid with dynamic columns and column filtering. I'm also setting a filter template for the columns I want to have this feature. Everything is working fine except for one thing I'm trying.

When I send the filter command on the client-side: 

1.tableView.filter(columnUnique, searchValue, condition);

I also set a css class on an element of my template.

I see this element changing but when the filter command is completed, it's gone.

Well, I implemented so far:

- The columns on the grid are defined during the page_init

- During this initialization, I set the filter templates too

This is an example of one of my templates:

01.           public TextTemplate(Page _page, RadGrid _grid, RadContextMenu _menu, GridColumnSetting _column)
02.        {
03.            page = _page;
04.            grid = _grid;
05.            menu = _menu;
06.            columnSettings = _column;
07. 
08.            panel = (Panel)page.LoadControl(typeof(Panel), null);
09.            panel.ID = "ftrPnl_text_" + columnSettings.DataMember;
10.            panel.CssClass = "ftrPnl";
11. 
12.            panel2 = (Panel)page.LoadControl(typeof(Panel), null);
13.            panel2.ID = "ftrIpt_text_" + columnSettings.DataMember;
14.            panel2.CssClass = "ftrIpt";
15. 
16.            textBox = (CustomTextBox)page.LoadControl("~/Controls/CustomTextBox.ascx");
17.            textBox.ID = "txt0_" + columnSettings.DataMember;
18.            textBox.ToolTip = columnSettings.ColumnToolTip;
19. 
20.            button = (Button)page.LoadControl(typeof(Button), null);
21.            button.ID = "btn_filter_" + columnSettings.DataMember;
22.            button.UseSubmitBehavior = false;
23.            button.CssClass = "ftrTxt rgFilter btn_filter";
24. 
25.            hidden = (HiddenField)page.LoadControl(typeof(HiddenField), null);
26.            hidden.ID = "hdn_filter_" + columnSettings.DataMember;
27.        }
28. 
29.        public void InstantiateIn(Control container)
30.        {
31.            textBox.OnClientKeyDown =
32.                "filterOnEnter('" + hidden.ID + "', 'text', '" + button.ID + "');";
33. 
34.            hidden.Value =
35.                grid.ClientID + FLP.SEPPROP +
36.                columnSettings.DataMember + FLP.SEPPROP +
37.                textBox.ClientID + FLP.SEPPROP +
38.                columnSettings.FilterFunction.AsString();
39. 
40.            button.OnClientClick = FilterButtonJS();
41. 
42.            panel2.Controls.Add(textBox);
43.            panel.Controls.Add(panel2);
44.            panel.Controls.Add(button);
45. 
46.            container.Controls.Add(panel);
47.            container.Controls.Add(hidden);
48.        }

2 Answers, 1 is accepted

Sort by
0
romulo~
Top achievements
Rank 1
answered on 01 Oct 2015, 08:49 PM

I might be missing something about life cycle and the template.

Is there any event of the grid I can check this filter template and try to update it?

0
Accepted
Eyup
Telerik team
answered on 06 Oct 2015, 11:25 AM
Hi RĂ´mulo,

You can use the approach demonstrated in the RadGridFilterTemplateProgrammatic.zip web site provided in the following post:
http://www.telerik.com/forums/how-to-persist-dropdownlist-selected-index-and-value-on-postback-from-radgrid-filtertemplate#GW3MyQLmVEmy8XzsmrHzeQ


Hope this helps.

Regards,
Eyup
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
romulo~
Top achievements
Rank 1
Answers by
romulo~
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or