Hello!
My goal:I have a WebDataGrid (WDG) that is using an OracleDataSource (ODS). I also have a form where the user may enter and submit a row to be added ODS and I'd like to add the row to the WDG using Javascript.
My problem:When I try to add a row to the WDG using Javascript, I'm forced to enable the WDG editing mode for the user. I don't want to do that: I want the user to use my form. More important, when I try to add a row to the WDG, there is an attempt to insert the row into the ODS, which I already did elsewhere in my code. In other words, I need to be able to add a row to the WDG without it causing an attempt to insert the row into the ODS, and ideally without enabling editing mode.
I chose not to use the built-in editing mode because two grids are involved (what's added to one grid depends on the selections in the other grid and both grids need separately updated) and because there are multiple functions (the user needs to be able to decide how the addition is made). Moreover, the data source is very slow, so refreshing the data for one or both grids is not a viable option.
While I appreciate any advice on an ideal solution (which may involve a significant change of approach), I'm on a tight schedule so I'd prefer the quickest option at this time. Thank you!
Hi bmv,
Thank you for posting in the community.
I am attaching a sample illustrating how rows can be added to your grid without enabling the grid editing behaviors: essentially after submitting the user information the row is firstly added to the datasource, and then the grid is rebound.
Please let me know if this configuration suits up your scenario.
Hi Peter,
Thank you for your quick response!
I don't have my project with me at the moment to experiment, but I think that -- because I'm using an OracleDataSource rather than DataTable -- rebinding the data source (such that it includes the new row) would involve re-querying the database, which takes a long time and is not a viable option for this application. Is that correct? I will verify as soon as I can.
Thank you for your replies.
Please note that when batch updating is enabled, the newly added rows will be inserted in the datasource on the next postback. The newly added rows can be selected in WebDataGrid, however by default the selection styles are not applied.
The selection styling for WebDataGrid is by default defined in the tbody>tr>td.igg_SelectedCell CSS class located in ig_dataGrid.css in the ig_res/Default folder. In order to apply the properties also to newly added rows, you can use !important:
tbody>tr>td.igg_SelectedCell{ background-color: Green !important;}
Regarding the styling of added rows, it is defined in the .igg_AddedRow th and .igg_Alt.igg_AddedRow th classes. A useful styling guide for WebDataGrid can be found at:
http://blogs.infragistics.com/blogs/engineering/archive/2010/08/25/webdatagrid-css-styling-guide.aspx
Please let me know if this helps.
No, I'm really looking for a way to add rows to the WDG without a postback. I'm already adding rows to the database through other means. I just mentioned batch updating because it let me do that, but it adds "queued rows" that are italicized and cannot be selected until after a postback. I need to be able to select rows that I add and a postback is not an option because it is too slow to requery for or store/restore the data.
I am attaching a sample illustrating your scenario (i.e. newly added rows are selectable). Please note that it is following the CSS styling suggestions from my previous post, with the addition that the tbody tr.igg_AddedRow td class was modified to alter the added row style.
Please let me know if you have any questions.
Please feel free to contact me if you need further assistance.