PDA

View Full Version : [CLOSED] Pb with update on HttpProxy/StoreDataHandler



Rod
Oct 08, 2008, 11:40 AM
Sorry to bother you again, but i'm clueless about this problem.
I'm trying to update some records from a gridpanel, with the help of the "HandlerUsing" sample. Only difference is that i'm using JSON serialization instead of XML.
I just can't understant why on my handler, updated records un the StoreDataHanlder looks like this :


{"Updated":[{"AdministrateurID":"1001","NomAdministrateur":"Dupond",
"PrenomAdministrateur":"John","EmailAdministrateur":"<A href='mailto:john@dupond.net","CleMD5PwdAdministrateur":"43C32AEFEB5480D98E5DF2EEAD2A4297","CompteAdministrateurActif":true,"IdUtilisateurCreation":"tempId","IdUtilisateurModification":"tempId","DateCreation":"2008-07-10T18:09:44","DateModification":"2008-08-01T15:22:49'>john@dupond.net",
"CleMD5PwdAdministrateur":"43C32AEFEB5480D98E5DF2EEAD2A4297",
"CompteAdministrateurActif":true,"IdUtilisateurCreation":"tempId",
"IdUtilisateurModification":"tempId","DateCreation":"2008-07-10T18:09:44","DateModification":"2008-08-01T15:22:49</A>"}]}

which looks fine, while my changeRecords doens't store any AdministrateurID. Other fiels are perfectly fines, and the changed values are sent properly.
The ReaderID of my JsonReader is set to AdministrateurID (I believe this is how it should be), but I can't find anything else in the sample about how to handle Primary keys.
What am I missing here?

Vladimir
Oct 08, 2008, 12:59 PM
Does the AdministrateurID present in GridPanel as Column and in store as field? Can you try to remove this column and field (but leave ReaderID as is ReaderID = "AdministrateurID "). I am not sure (and I'll investigate) but if Store contains Field which is id then can be some problems. I'll investigate it now. Please let me know about results

Rod
Oct 08, 2008, 1:09 PM
Sorry, should have precised it, but I tried both already, as I saw in the example that adding it as a field wasnt necessary, and the result is the same.
Btw, also forgot, but I'm deserializing to Linq entities).

Out of curiosity, how are we supposed to do in case of multiple ID's? ReaderID="Id1,Id2,etc..."?
-----

Just tried with my AdministratorID as a field in the gridpanel, and it displays an empty string in both cases -_-
Will investigate why before making you lose more time :/

Rod
Oct 08, 2008, 1:15 PM
Something's weird here :/
Here the json from my proxy (regular handler) :


{totalCount:2,'Administrateurs':[{AdministrateurId:"4b71ef2f-4ad1-46da-90f4-9eca6f4b4fe5",NomAdministrateur:"Nom1",PrenomAdministrateur:"Prenom1",EmailAdministrateur:"email1@domain.com",CleMD5PwdAdministrateur:"43C32AEFEB5480D98E5DF2EEAD2A4297",CompteAdministrateurActif:true,IdUtilisateurCreat ion:"tempId",IdUtilisateurModification:"tempId",DateCreation:"2008-07-10T18:09:44",DateModification:"2008-08-01T15:22:49"},{AdministrateurId:"e259c066-115b-4289-a2b1-79e47e90dcac",NomAdministrateur:"Nom2",PrenomAdministrateur:"Prenom2",EmailAdministrateur:"email2@domain.com",CleMD5PwdAdministrateur:"43C32AEFEB5480D98E5DF2EEAD2A4297",CompteAdministrateurActif:true,IdUtilisateurCreat ion:"tempId",IdUtilisateurModification:"tempId",DateCreation:"2008-08-22T10:27:23",DateModification:"2008-09-01T15:51:20 ('email1@domain.com",CleMD5PwdAdministrateur:"43C32AEFEB5480D98E5DF2EEAD2A4297",CompteAdministrateurActif:true,IdUtilisateurCreat ion:"tempId",IdUtilisateurModification:"tempId",DateCreation:"2008-07-10T18:09:44",DateModification:"2008-08-01T15:22:49"},{AdministrateurId:"e259c066-115b-4289-a2b1-79e47e90dcac",NomAdministrateur:"Nom2",PrenomAdministrateur:"Prenom2",EmailAdministrateur:"email2@domain.com",CleMD5PwdAdministrateur:"43C32AEFEB5480D98E5DF2EEAD2A4297",CompteAdministrateurActif:true,IdUtilisateurCreat ion:"tempId",IdUtilisateurModification:"tempId",DateCreation:"2008-08-22T10:27:23",DateModification:"2008-09-01T15:51:20')"}]}


And here is my store and gridpanel.


<ext:Store runat="server" ID="Store1" AutoLoad="true" RemoteSort="true">
<Proxy>
<ext:HttpProxy runat="server" Method="POST" Url="/Profils/WebControls/AdministrateursControler.ashx" />
</Proxy>
<UpdateProxy>
<ext:HttpWriteProxy runat="server" Method="POST" Url="/Profils/WebControls/AdministrateurUpdater.ashx" />
</UpdateProxy>
<Reader>
<ext:JsonReader TotalProperty="totalCount" Root="Administrateurs" ReaderID="AdministrateurID">
<Fields>
<ext:RecordField Name="NomAdministrateur" />
<ext:RecordField Name="PrenomAdministrateur" />
<ext:RecordField Name="EmailAdministrateur" />
<ext:RecordField Name="CleMD5PwdAdministrateur" />
<ext:RecordField Name="CompteAdministrateurActif" />
<ext:RecordField Name="IdUtilisateurCreation" />
<ext:RecordField Name="IdUtilisateurModification" />
<ext:RecordField Name="DateCreation" />
<ext:RecordField Name="DateModification" />
</Fields>
</ext:JsonReader>
</Reader>
<AutoLoadParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="limit" Value="5" Mode="Raw" />
</AutoLoadParams>
<SortInfo Field="NomAdministrateur" Direction="ASC" />
<Listeners>
<LoadException Handler="Ext.MessageBox.alert('Erreur lors du chargement', response.statusText);" />
</Listeners>
</ext:Store>
<ext:Panel ID="AdministrateursPanel" runat="server" Title="Gestion des administrateurs"
Border="false">
<Content>
<ext:GridPanel runat="server" ID="GridPanel1" StoreID="Store1" Title="Administrateurs"
Header="false" Height="175" AutoExpandColumn="Administrateur">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn />
<ext:Column ColumnID="AdministrateurID" Header="Id" DataIndex="AdministrateurID"
Sortable="true">
</ext:Column>
<ext:Column ColumnID="Administrateur" Header="Nom complet" DataIndex="LastName" Sortable="true">
<Renderer Handler="return ''+record.data['NomAdministrateur']+','+record.data['PrenomAdministrateur']" />
</ext:Column>
<ext:Column ColumnID="EmailAdministrateur" Header="Email" DataIndex="EmailAdministrateur"
Sortable="true">
</ext:Column>
<ext:CheckColumn ColumnID="CompteAdministrateurActif" Header="Compte actif" DataIndex="CompteAdministrateurActif"
Sortable="false" />
<ext:Column ColumnID="Details" Header="Details" Width="50" Align="Center" Fixed="true"
MenuDisabled="true" Resizable="false">
<Renderer Fn="administrateurDetailsRender" />
</ext:Column>
<ext:Column ColumnID="Delete" Header="Supprimer" Width="50" Align="Center" Fixed="true"
MenuDisabled="true" Resizable="false">
<Renderer Fn="administrateurDeleteRender" />
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</Content>
</ext:Panel>


Id's are correctly sent but seems to disappear somewhere :/
Am I setting them to an empty string somewhere?

Vladimir
Oct 08, 2008, 1:25 PM
If you need column with ID then need to add to fields


<ext:RecordField Name="AdministrateurID" />

Rod
Oct 08, 2008, 1:27 PM
Actually I removed it during the copy/paste as I thought it wasn't necessary, but I tried with and without AdministrateurID in the reader's fields, with the same behavior.

Vladimir
Oct 08, 2008, 1:37 PM
Can you create simple example, zip it and post? I'll try to investigate what happens

Rod
Oct 08, 2008, 1:51 PM
Ok I'll do that tomorrow.

Rod
Oct 09, 2008, 7:06 AM
Just sent it to Geoff, as I don't have your email adress.
Try to use the Edit window, and check what is sent to Updater handler.
Plz tell me if this is too messy.

Vladimir
Oct 09, 2008, 9:31 AM
Hi Rod,

Please be aware that reader fields are case-sensitive. The 'AdministrateurID' and 'AdministrateurId' are different names
Plus if you need to represent information in grid column then the record field must exists in Reader


<p class="MsoListParagraph" style="text-indent: -18pt;">
</p>

Rod
Oct 09, 2008, 9:36 AM
Perfectly working now, big thx Vlad :)
AdministratorID being in grid column was just cause I forgot to remove it while cleaning, but the pb was indeed AdministrateurID/Id case.