Example for editable simple grid wanted

10 replies. Last post: September 27, 2011 4:12 AM by Eric
Tags :
  • New Discussion
  • New Question
  • New Product Feedback
Eric Member

Hello

We have a simple WebGrid (currently using version 6) that displays some rows from the database (unbound) where the user can edit one column and add/remove additional rows with a button. The changed data does not go into the database until the user confirms he wants to save everything together or maybe cancels out.

The WebGrid is defined with AllowAutoDataCaching="false", because caching does not work with our web farm setup.

The WebGrid has a DataKeyField defined and some columns, all read-only, except one for the Weight with AggregateFunction="Sum", DataFormatString="#0.00", DataType="System.Double", EditType="TextBox".

The grid_InitializeDataSource function dynamically creates the rows based on a class variable and assigns the created DataTable to e.DataSource. The content of the class variable is filled in Page_Load.

Because WebGrid fails to update the Sum on hitting Enter, we have a ClientSideEvent OnExitEditMode defined. There we calculate the current total and update it with grid.RootTable.GetElement(WG40.COLFOOTER,WG40.HTMLTABLE).rows[1].cells[...].innerText=...

(Adding/Deleting rows works by the user clicking a button and in the event adding a row to grid.DataSource and calling grid.RebindDataSource. Not relevant to the problem.)

Now the problem is that after every value edit and selection change afterwards, the InitializeDataSource event gets called again, overwriting the edited user values and the total calculation also gets wrong (the screen still shows the user values though). I think this happened after our move to the web farm and disabling the caching mentioned earlier.

What is the proposed way to do this without caching data within the grid?

Eric

All times are GMT -5. The time now is 2:27 AM.
Previous Next