PDA

View Full Version : [CLOSED] GridPanel Store UseIdConfirmation



Timothy
Sep 09, 2008, 8:30 PM
Hello,

When using UseIdConfirmation with a Store and I insert an empty record into a GridPanel; once I issue a GridPanel.save() the BeforeRecordInserted and AfterRecordInserted do not fire. The Updated and Deleted events do however fire if I've done one of them.

I'm guessing this is because my new record does not have an Id but I think it should still fire.

Can you confirm?

Cheers,
Timothy

Vladimir
Sep 10, 2008, 6:19 AM
Hi Timothy,

I want to give some clarifications about UseIdConfirmation

1. The ReaderID in Reader specification is required if you use UseIdConfirmation
2. The Id genereates automatically for inserted records on client side. But I want describe two cases:
<ul> The ReaderID is specified but the id field is absent in reader fields
and grid columns. In this case the id value will be generate and submit to server during saving[/list]

<Reader>
<ext:XmlReader Record="Customer" ReaderID="CustomerId">
<Fields>
<ext:RecordField Name="CompanyName" />
<ext:RecordField Name="ContactName" />
</Fields>
</ext:XmlReader>
</Reader>
<ul> The ReaderID is specified and id field exists in record fields. In this case the id will be generate automatically but during save it will be override by default value of reader field (by default empty value).
[/list]

<Reader>
<ext:XmlReader Record="Customer" ReaderID="CustomerId">
<Fields>
<ext:RecordField Name="CustomerId" />
<ext:RecordField Name="CompanyName" />
<ext:RecordField Name="ContactName" />
</Fields>
</ext:XmlReader>
</Reader>


The confirmation list can't contains empty id values, so will be throwing exception on server side. If you need to show id in GridPanel then you must set unique id for each inserted record on CLIENT side. It can be temporary unique id (on server side you can set real id in confirmation list and this id will replace temporary id )

I'll discuss with Geoffrey the confirmation logic and may be we changes it. I let you know discussing result tomorrow

Timothy
Sep 10, 2008, 8:35 AM
Thanks vlad, but what if your Id is not integer based but rather guid based ? :)

Cheers,
Timothy

Vladimir
Sep 10, 2008, 8:46 AM
It is not problem. On client side the autogenerated id will be int (the js is not strong-typed language). On server side in confirmation record this id will be convert to string (the confirmation record in confirmation list represent oldId and newId as string). So, you can set newId on server as GUID transforming it to string. Then on client side the oldId will be replaced by newId

Timothy
Sep 10, 2008, 10:05 AM
OK, will give it a try.