Hi,
I’d like to use the startEditingNew() method to add a record to one of my ListGrids, and by means of a RestDataSource, to my database table.
This particular ListGrid displays items based on a project selected from another ListGrid, and on a customer selected from a TreeGrid. This is done using a series of SearchForms.
I need to pass the selected customer ID and project ID from the other controls to the REST add() function somehow, so that I’ll know for which customer and project this item is being added.
What’s the best way to do this?
Thanks,
Mike
You can pass initial values to the newly created record via the first parameter of startEditingNew(), and these will be part of the data pass in the “add” dsRequest when that record is saved.
Thanks for the quick response!
What format should be used for the data? The parameter type just says “object”, and I don’t see any examples.
“name1=value1&name2=value2”
…or something like that?
Thanks,
Mike
Object means ordinary JavaScript Object. Search the docs for Object Literal for some examples.
Thank you, that worked quite well.
However, when I finish editing the new row (by tabbing away from the last field), I select another customer from the TreeGrid. Then I select back to the customer I just added an item for, and I no longer see the record I just added.
The only way to get it to appear again is to close and re-open the browser, or… before clicking away to another customer, I first have to click to sort the ListGrid. That seems to make the new record “stick”.
(I’m using a SearchForm to filter the items on the ListGrid.)
Is there something else I have to do, perhaps some function that needs to be called after the new row is finished being edited to make it “stick”?
Thanks,
Mike
I also have a similar problem when deleting a record.
The deleted record disappears, but then reappears a moment later. The delete does not seem to “take”, until I close and re-open the browser.
Thanks,
Mike
In both cases it’s likely something is going wrong with cache sync. You are expected to return the record-as-saved for an “add” operation, and the primary keys for a delete operation. You can troubleshoot what’s going by enabling the “ResultSet” log category in the Developer Console.
Can I use the Developer Console if I’m using Client-side only?
Mike
Yes, all the tools within it are available except server log viewing.
I have a delete button which calls:
this.targetGrid.removeSelectedData();
My RestDataSource returns the requested data (just the key field).
From the Developer Console, I see that it performs the delete, but then performs a fetch immediately after. The ListGrid is not cleared between these two actions, so the end result is that records are repeated.
Any hints how I can fix this behavior?
The fetch after the delete is most likely performed by the FindForm I have in place.
Thanks,
Mike
By the way, the Developer Console regularly freezes my app.
I’m using IE7 and version 6 of SmartClient.
I can usually see a couple fetch operations, then it freezes.
Mike
Hi Mike,
Hmm.. never seen the Developer Console freeze before, and of course we run that configuration all the time. If you have enabled lots of log categories (or set the default log priority to debug) the volume of information logged will of course slow down your machine. Otherwise the recommendation would be to re-install Windows 
On the extra fetch - there is a known bug regarding re-fetch after delete in SmartClient 6.0, with a patch available Addendums forum. Or your could just upgrade to 6.5.
Thank you!
I was hoping the re-fetch was a bug, since I couldn’t see anything I was doing wrong. I think I’m getting the hang of this…
Mike