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
close icon

Getting row numbers in the data-bound grid

I've been evaluating the Syncfusion grid controls, and was surprised to find that in the data-bound grid, there's no simple way to get row numbering (in the header). Is this not possible?

Also, I don't understand why there was the need to split your class hierarchy into 2 separate classes - one for the normal grid, and one for the data-bound grid. The normal grid has several UI properties that don't seem to be there in the data-bound grid.

So anyone wanting the best of both worlds has to either :-

1) take the data-bound grid and then write a lot of extra code so it looks as good as the normal grid (specially if you want excel like features)

2) take the unbound grid and do your own data binding code

Seems to me that that's a lot of extra work considering people'd buy a 3rd party grid to save on some development time.

Am I missing something obvious here?


1 Reply

AD Administrator Syncfusion Team November 27, 2007 08:55 AM UTC

If you are referring to GridControl and GridDataBoundGrid, they do derived from the same class GridControlBase. They do both have the same property grid.Model which does hold lots of common properties. Their main difference is that one is a cell oriented grid (storing all information and properties on a cell by cell basis in its own data cache) and the other is a bound, column oriented grid which does not have a local datastore setup to store any information on a cell by cell basis. The idea is that for bound data which might be millions of records with similar data in each column, there is no need to allocate the overhead required to manage cell by cell data in such cases.

If you want to see the row numbers in a GridDataBoundGrid, here is one way. Subscribe to the Model.QueryCellStyleInfo event.

this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(Model_QueryCellInfo);


Then use code like this in the handler.

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex == 0)
{
e.Style.CellType = "Header";
e.Style.Text = e.RowIndex.ToString();
e.Style.Font.Bold = false;
}
e.Style.CellTipText = e.Style.CellType;
}



Loader.
Live Chat Icon For mobile
Up arrow icon