iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have two page("A" and "B"), one webgrid in "A" page, when user input filter key words into FilterBar then apply Filter, click one row from "A" page to "B" page, when return back to "A" page from "B" page after click "return" button or "save" button, how to kept the FilterBar state in "A" page?
thanks
Hello,
Thank you for your code.My apologies for the inconvenience. I can replicate your issue on my end as well.However, to set the filter text and filter type, you could use this following code below (in Page_Load server side event):
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["ses_filter_columns"] != null) { WebGridFilterCollection wgfc = (WebGridFilterCollection)Session["ses_filter_columns"]; int iFilterCount = wgfc.Count; for (int i = 0; i < iFilterCount; i++) { var myFilter = new WebGridFilter(); myFilter.ColumnMember = wgfc[i].ColumnMember; myFilter.FilterText = wgfc[i].FilterText; myFilter.FilterType = wgfc[i].FilterType; WebGrid1.RootTable.FilteredColumns.Add(myFilter); } } } }
Hope this helps. Thank you.Regards,Hans.
To implement this scenario, first, you should get the filter value in filter column.Here’s the example snippet code how to get the filter value (in client side event):
var WebGrid1 = ISGetObject("WebGrid1"); var filter = WebGrid1.RootTable.GetFilterRow(); var filterRow = WebGrid1.RootTable.ToRowObject(filter); // You could choose the column by the column's name var filterCell = filterRow.GetCells().GetNamedItem("ContactName"); var filterText = filterCell.Text;
I suggest you to save the filter value to session variable.
Then, to set back the filter value (or filter bar state), please use this following snippet code (in client side event):
var WebGrid1 = ISGetObject("WebGrid1"); var newFilter = new WebGridFilter(); newFilter.ColumnMember = "ContactName"; newFilter.FilterType = "Like"; newFilter.FilterText = filterText; // Your filter value WebGrid1.RootTable.FilteredColumns.Add(newFilter); WebGrid1.RootTable.UpdateUI(); WebGrid1.Refresh();
For further information about add filter value programmatically, please see in our WebGrid’s documentation, on “How-to: Add and remove Filtered Column programmatically” section.
Hans, thanks for you reply, i set AutomaticFilter="false" in page "A", then add follow code
protected void wegbrid1_CustomFilter(object sender, FilterEventArgs e) { // save filter state Session["ses_filter_columns"] = wegbrid1.RootTable.FilteredColumns; }
in Page_Load event add follow code
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["ses_filter_columns"] != null) { WebGridFilterCollection wgfc = (WebGridFilterCollection)Session["ses_filter_columns"]; int iFilterCount = wgfc.Count; for (int i = 0; i < iFilterCount ; i++) { webgrid1.RootTable.FilteredColumns.Add(wgfc[i]); } } } }
the data of page "A" display ok when return page "B", but the filter text of FilterBar disappear.
so i want to show filter text and filter type i selected.
Regards,Roger
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname