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
HelloWe are using WebGrid version 6. We want to find out how to get a list back of filtered rows server side. I assume this must be easy and we are missing something obvious.For example, the grid could display say 500 rows over say, 20 pages. The user could then filter these results to return say 75 rows over 3 pages. We want to find out these filtered rows could be discovered server side. So we could have a button at the bottom of the page for example "do something to filtered results". At present we are checking the RootTable.Rows property but this just gives us all rows on the current page only.Find attached a small code snippet of the essential code we use
<iswebgrid:webgrid id="WebGridMain" runat="server" allowautodatacaching="false" onexport="WebGridMain_Export" onupdaterow="WebGridMain_UpdateRow" ondeleterow="WebGridMain_DeleteRow" > <LayoutSettings AllowColumnFreezing="Yes" AllowDelete="Yes" AllowEdit="Yes" AllowExport="Yes" AllowFilter="Yes" AllowSorting="Yes" AlwaysShowHelpButton="False" HeaderClickAction="SortMulti" AutoHeight="true" FocusNewRowOnLastCell="True" GridLineColor="#DCB0C8" GridLines="Vertical" CellPaddingDefault="5" PagingMode="ClassicPaging" PagingExportMode ="ExportAllData" PagingSize="25" PagingLoadMode="Automatic" PagingStyleUI="FirstPrevNextLast"> <FreezePaneSettings AbsoluteScrolling="true" ShowInContextMenu="True" /> <various styles etc..............> </LayoutSettings> </iswebgrid:webgrid> /// <summary>/// Populate the grid with the correct data/// </summary>public void Populate(){ // Fill in the grid datasource WebGridMain.DataSource = GridManager.PopulateGridData(); // Do the databind if (!IsPostBack) { WebGridMain.DataBind(); } else if (IsPostBack) { WebGridMain.RebindDataSource(); }} //// ***This is where we want the filtered result set so we can do something to them***// private void AButtonClickEvent(){ // We are using RootTable.Rows but this only gives us the filtered result set for the current page WebGridRowCollection rows = WebGridMain.RootTable.Rows; // Do something with rows here - }
Thanks
Please try to obtain the filtered rows collection from the default view of the data table of WebGrid data source.
I enclosed one simple sample that shows how to obtain the filtered rows object from data table’s default view. In the attached sample, I bind WebGrid to ‘Products’ table of Northwind database. Initially (without filter applied), the table will return 77 rows. With ‘Discontinued’ column filter expression is set to ‘false’ (filter products that has discontinued status is false), the table will return 69 rows.
The filtered rows object can be obtained by using
public partial class GetFilteredRowsOnServerSide : System.Web.UI.Page { dsNorthwind.ProductsDataTable dt = new dsNorthwind.ProductsDataTable(); dsNorthwindTableAdapters.ProductsTableAdapter da = new dsNorthwindTableAdapters.ProductsTableAdapter(); protected void Page_Load(object sender, EventArgs e) { } protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { da.Fill(dt); e.DataSource = dt; } protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e) { if (!IsPostBack) WebGrid1.RetrieveStructure(); } protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < dt.DefaultView.Count; i++) TextBox1.Text += dt.DefaultView[i].Row.ItemArray[1] + " ; \n"; } }
Hope this help.
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