We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

limiting the no of rows in the grid.

hi, I have a grid grouping grid. I have a requirement to limit the number of rows appearing on the grid. Say , for example I have a filter col1 >0 and I want to see only the first 10 rows and last 15 rows that satisfy this condition. How to go about it? I have applied the filter condition to the datasource.Is there any way to limit the number of rows from the grid? regards, Catinat

8 Replies

CV Catinat Velmourougan August 4, 2005 02:36 PM UTC

hi clay, Is there some property which i can set? I have searched on the forums couldnt find anything. regards, catinat >hi, >I have a grid grouping grid. >I have a requirement to limit the number of rows appearing on the grid. >Say , for example I have a filter col1 >0 and I want to see only the first 10 rows and last 15 rows that satisfy this condition. How to go about it? > >I have applied the filter condition to the datasource.Is there any way to limit the number of rows from the grid? > >regards, >Catinat


AD Administrator Syncfusion Team August 4, 2005 02:53 PM UTC

There is no property setting that would give you this behavior. There is a QueryRecordMeetsFilterCriteria event that you can use along with an unbound column to get this behavior. Here is a little sample that displays teh first 2 and last 2 records in a filter. http://www.syncfusion.com/Support/user/uploads/GGC_FilterRestrictions_b5c704ea.zip


CV Catinat Velmourougan August 5, 2005 04:28 AM UTC

hi clay, I went through the sample.It solves my problem. In the sample, theres the following code snippet: //add unbound column to hold position in filter and hide it this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("positionInFilter"); this.gridGroupingControl1.QueryValue += new FieldValueEventHandler(gridGroupingControl1_QueryValue); this.gridGroupingControl1.TableDescriptor.VisibleColumns.Remove("positionInFilter"); This column "positionInFilter" is not used anywhere.Can I know the purpose of this column? This led me to another approach.Say I can add an rownumber column when building the datasource table and then apply a filter rownum < 3 or rownum > rowcount - 2. Will this work? I just want your opinion on this approach. regards, Catinat


CV Catinat Velmourougan August 5, 2005 06:48 AM UTC

What about these methods? Are they helpful? sfgAssetView is of type Syncfusion.Forms.Grid.Grouping.GridGroupingControl this.sfgAssetView.Table.TableModel.Rows.RemoveRange(0,5); this.sfgAssetView.Table.TableModel.RowCount = 10; When I set this I get the following error: Capgroup.IMSFI.Awb.Main.exe'': Loaded ''d:\cgc\awb\awbapp\awbmain\bin\debug\capgroup.imsfi.common.businesslogic.dll'', Symbols loaded. catched at Syncfusion.Windows.Forms.Grid.GridModelRowColOperations.RemoveRange(Int32 from, Int32 last) in :line 0 System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: count at Syncfusion.Collections.SFTable.RemoveRows(Int32 rowIndex, Int32 count) at Syncfusion.Windows.Forms.Grid.GridData.RemoveRows(Int32 rowIndex, Int32 count) at Syncfusion.Windows.Forms.Grid.GridModelRowOperations.DataRemoveRange(Int32 removeAt, Int32 count) at Syncfusion.Windows.Forms.Grid.GridModelRowColOperations.RemoveRange(Int32 from, Int32 last) >hi clay, > >I went through the sample.It solves my problem. >In the sample, theres the following code snippet: > >//add unbound column to hold position in filter and hide it > this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("positionInFilter"); > this.gridGroupingControl1.QueryValue += new FieldValueEventHandler(gridGroupingControl1_QueryValue); > this.gridGroupingControl1.TableDescriptor.VisibleColumns.Remove("positionInFilter"); > >This column "positionInFilter" is not used anywhere.Can I know the purpose of this column? > >This led me to another approach.Say I can add an rownumber column when building the datasource table and then apply a filter rownum < 3 or rownum > rowcount - 2. Will this work? I just want your opinion on this approach. > >regards, >Catinat


AD Administrator Syncfusion Team August 5, 2005 10:12 AM UTC

The unbound fields and QueryValue are not used. They were left over from another try at doing this task. They should be removed. Here is the changed sample. http://www.syncfusion.com/Support/user/uploads/GGC_FilterRestrictions_a1d45d30.zip The idea of filtering a row index column may not work for this reason. It is not the index of the record in the original table that needs to be tested. Instead, it is the index in the filtered results that needs to be considererd. So, you would somehow reset these index values everytime there was a filter but you would not be able to until the filter was completed. Then you would have to refilter. Sort of a chicken and egg problem.


CV Catinat Velmourougan August 5, 2005 12:57 PM UTC

hi clay, Theres one more catch ( specific to our design) when we use this approach, the filter condition is not being applied to the grid, but we apply to the datasource of the grid.So we dont have any record filters. So the event( QueryRecordMeetsFilterCriteria)is not getting fired!!!! So how to go about in this scenario??? regards, catinat


CV Catinat Velmourougan August 5, 2005 01:35 PM UTC

hi, This one works! Do you forsee anhy problems with this piece of code? for( int i = 0; i < this.sfgAssetView.Table.TableModel.RowCount; i++) { if ( i > 20) { this.sfgAssetView.Table.TableModel.Rows.Hidden[i] = true; } } But since it loops through entire set of rows once, we are looking at other ways.


AD Administrator Syncfusion Team August 5, 2005 02:07 PM UTC

If you are not using the grid''s filter support, then trying to hide the rows will have to be done in some other way. If you are doing a sql query on your database to get the filtered results to display in the grid, I think you can set up the query to pull only a subset of the filter. Not really sure of teh syntax though. As far as dynamically hiding the rows, this may work for a simple flat table but there also may be scrollbar problems with nested tables and such if you are using them.

Loader.
Up arrow icon