Get row count in SmartBatchUpdateScenario

4 replies. Last post: April 8, 2010 3:20 AM by Herman Cordes
Tags :
  • New Discussion
  • New Question
  • New Product Feedback

Currently I'm working with a SmartBatchUpdateScenario. However, the possibility exists that a record gets added with a duplicate KeyValue. The WebGrid gives me a decent error message about that, but I'd like to detect that in advance and suppress the message. The message is not relevant for users in my case.

So my first solution to detect that case was to loop through all grid rows and check each keyvalue to the keyvalue of the record to be added. If a match is found, the record is not added. I'm encountering one problem hereby: the number of grid rows isn't returning the correct number of rows.

Concrete steps:

  1. The first row in an empty grid that will be added checks the KeyValue exists. The number of rows is 0, so it doesn't exist and will be added.
  2. The second row in a grid (with one row) will check the KeyValue exists. However, the number of rows is still 0, so the record gets added. Even if this record is the same as the first one.

I'm using the attachment from this thread: http://www.intersoftpt.com/Community/WebGrid/WebGrid-two-way-binding-issue/. Several ways to get the row count:

var grid = ISGetObject("WebGrid1");
alert(grid.TotalLoadedRows); // Doesn't change after record has been added at client side.
alert(grid.TotalRows);// Doesn't change after record has been added at client side.
alert(grid.RootTable.Rows); // Is null.
alert(grid.RootTable.Rows.length); // Throws error.

 

Questions:

  1. Am I doing something wrong with this solution?
  2. Should I be using another property to obtain rowcount in a SmartBatchUpdateScenario?
  3. Is there another way to detect duplicate KeyValues in rows?

Thanks in advance.

All times are GMT -5. The time now is 3:53 PM.
Previous Next