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

GDBG AddNew row vs. data table in event handler

Hi, we have a GDBG with three columns - let's call them A, B, C and D - which are as follows :

A - ID (integer, readonly)
B - string column (changeable)
C - string column (readonly)
D - button (clickable)

The grid data source is set to a data table which contains columns A - C and an undisplayed column E.

We have a CellButtonClicked handler for the grid which is supposed to fill in columns C and D based on some user interaction. However, the problem is that for the AddNew row at the bottom of the grid, no corresponding data row exists yet in the data table when the handler is executed.

Is there a good way of dealing with this ? Thanks for any assistance !
-Rob

4 Replies

RY Rob Yang May 17, 2007 09:14 PM UTC

Sorry, let me try that again - I was a little distracted while typing that :)

>Hi, we have a GDBG with four columns - let's call them A, B, C and D - which are as follows :

A - ID (integer, readonly)
B - string column (changeable)
C - string column (readonly)
D - button (clickable)

The grid data source is set to a data table which contains columns A through C and an undisplayed column E.

We have a CellButtonClicked handler for the grid which is supposed to fill in columns C and E based on some user interaction. However, the problem is that for the AddNew row at the bottom of the grid, no corresponding data row exists yet in the data table when the handler is executed.

Is there a good way of dealing with this ? Thanks for any assistance !
-Rob


SA Saravanan A Syncfusion Team May 17, 2007 09:45 PM UTC

Hi Rob,

In GDBG, the AddNew row is used to add the new record to the underlying datasource at the runtime. When the user enter any data in that row and move to some other row then Binder.EndEdit() method will be called internally and that will add this new row to the datasource. So till you navigate to some other row after editing it for the first time, there wont be any record corresponding to that row in the datasource.
If you dont want this addnew row the set the EnableAddNew property of the GDBG to false.


Best Regards,
Saravanan.


RY Rob Yang May 18, 2007 01:45 AM UTC

Thanks Saravanan, that is helpful to know.

We would like to allow the user to add new rows via the AddNew row. When the user clicks the button in the AddNew row, we want the columns C and E to be filled in. However, I'm not sure what steps need to be taken programmatically - simply calling Binder.EndEdit() does not seem to add a new row. Is what we want to do possible ?

Thanks !
-Rob

>Hi Rob,

In GDBG, the AddNew row is used to add the new record to the underlying datasource at the runtime. When the user enter any data in that row and move to some other row then Binder.EndEdit() method will be called internally and that will add this new row to the datasource. So till you navigate to some other row after editing it for the first time, there wont be any record corresponding to that row in the datasource.
If you dont want this addnew row the set the EnableAddNew property of the GDBG to false.


Best Regards,
Saravanan.


RY Rob Yang May 18, 2007 02:33 AM UTC

Actually never mind, it seems that this does what we need :

grid.Binder.EndEdit();
grid.CurrentCell.MoveTo(e.RowIndex - 1, e.ColIndex);
grid.CurrentCell.MoveTo(e.RowIndex, e.ColIndex);

Thanks again !
-Rob

>Thanks Saravanan, that is helpful to know.

We would like to allow the user to add new rows via the AddNew row. When the user clicks the button in the AddNew row, we want the columns C and E to be filled in. However, I'm not sure what steps need to be taken programmatically - simply calling Binder.EndEdit() does not seem to add a new row. Is what we want to do possible ?

Thanks !
-Rob

>Hi Rob,

In GDBG, the AddNew row is used to add the new record to the underlying datasource at the runtime. When the user enter any data in that row and move to some other row then Binder.EndEdit() method will be called internally and that will add this new row to the datasource. So till you navigate to some other row after editing it for the first time, there wont be any record corresponding to that row in the datasource.
If you dont want this addnew row the set the EnableAddNew property of the GDBG to false.


Best Regards,
Saravanan.

Loader.
Live Chat Icon For mobile
Up arrow icon