Feb 24, 2012, 12:08 AM
record id from rowselect listener returns generated id
I tried to understand where the problem is, but I really don't know how to resolve this.
I have a gridpanel which is bound after a first trip with fresh new records form the database.
I will try to post a working sample if needed, however I suspect that i just don't look for the right record property.
In a page I have a formpanel and a master gridpanel sharing the same store.
In the formpanel I have a detail grid with other data and a separate store.
In the first step the user compiles the form and submit data.
In this first step (i.e. when the page is first loaded) the store have no dataBind().
I successfully obtained the changeddata of both stores and saved master-detail informations to the database via direct event.
After saving I follow these steps in order to have records back from database, since my objects must include extra informations:
I can easily fill the form using the
I implemented a direct method to retrieve the related details for the other grid, trying to pass the id of the master record to the direct method, but looking at its value I see that it is a client generated id (something like -200 etc.).
here is the code for the grid and the master store:
the parameter idpart is correctly sent from the direct method but it is not the record id I expected.
As far as i could understand I thought that if the IDProperty is set, then this is used also as id for the record... is the same id for the gridpanel bound to the store, or am I looking at the wrong property?
All the examples i have seen refer to this property to identify the selected record.
Thanks in advance!
I have a gridpanel which is bound after a first trip with fresh new records form the database.
I will try to post a working sample if needed, however I suspect that i just don't look for the right record property.
In a page I have a formpanel and a master gridpanel sharing the same store.
In the formpanel I have a detail grid with other data and a separate store.
In the first step the user compiles the form and submit data.
In this first step (i.e. when the page is first loaded) the store have no dataBind().
I successfully obtained the changeddata of both stores and saved master-detail informations to the database via direct event.
After saving I follow these steps in order to have records back from database, since my objects must include extra informations:
//retrieve data for the master grid/store
var partProvider = new ParticellePif02CollectionProvider();
var partcoll = partProvider.Find(terreno.IdPif01Pif02);
//retrieve data for the detail grid
var varProvider = new VarietaPif08CollectionProvider();
varietacoll = varProvider.Find(terreno.IdPif02);
//otherwise records are marked dirty, I don't know why
StoreTerreni.CommitChanges();
storeVarieta.CommitChanges();
//databind both stores
StoreTerreni.DataSource = partcoll;
storeVarieta.DataSource = varietacoll;
StoreTerreni.DataBind();
storeVarieta.DataBind();
After this first insert user could modify other records selecting them from the master grid.I can easily fill the form using the
.getForm().loadRecord(record)
in the rowselect listener.I implemented a direct method to retrieve the related details for the other grid, trying to pass the id of the master record to the direct method, but looking at its value I see that it is a client generated id (something like -200 etc.).
here is the code for the grid and the master store:
<ext:GridPanel
runat="server"
ID="grdTerreni"
TrackMouseOver="true"
StripeRows="true"
Title="Elenco Terreni"
AnchorHorizontal="100%"
Height="350">
<Store>
<ext:Store runat="server" ID="StoreTerreni" SkipIdForNewRecords="false">
<Reader>
<ext:JsonReader IDProperty="IdPif02">
<Fields>
<ext:RecordField Name="IdPif01Pif02" ServerMapping="IdPif01Pif02.Value" />
<ext:RecordField Name="DescrizionePif07" ServerMapping="DescrizionePif07.Value" />
<ext:RecordField Name="ComunePif07Pif02" ServerMapping="ComunePif07Pif02.Value"/>
<ext:RecordField Name="DesccondimpallPif02" ServerMapping="DesccondimpallPif02.Value" />
<ext:RecordField Name="DescondambPif02" ServerMapping="DescondambPif02.Value" />
<ext:RecordField Name="FoglioPf02" ServerMapping="FoglioPf02.Value" />
<ext:RecordField Name="ParticellaPif02" ServerMapping="ParticellaPif02.Value"/>
<ext:RecordField Name="SuphaPif02" ServerMapping="SuphaPif02.Value" />
<ext:RecordField Name="SupaaPif02" ServerMapping="SupaaPif02.Value" />
<ext:RecordField Name="SuptotPif02" ServerMapping="SuptotPif02.Value" />
<ext:RecordField Name="PrPif02" ServerMapping="PrPif02.Value" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="Località" DataIndex="DescrizionePif07" />
<ext:Column Header="Foglio" DataIndex="FoglioPf02" />
<ext:Column Header="Particella" DataIndex="ParticellaPif02"/>
<ext:Column Header="Superficie HA" DataIndex="SuphaPif02"/>
<ext:Column Header="Superficie AA" DataIndex="SupaaPif02"/>
<ext:Column Header="Superficie Totale" DataIndex="SuptotPif02"/>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="true" >
<Listeners>
<RowSelect Handler="#{frmpnlTerreni}.getForm().loadRecord(record);Ext.net.DirectMethods.LoadVarieta(this.getSelected().id);"/>
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
this is the direct method to fill the detail grid related to the selected master record:[DirectMethod(ShowMask = true)]
public void LoadVarieta(string idpart) //the parameter passed results in a negative integer as id for the record from the selected grid row
{
var varietaProv = new VarietaPif08CollectionProvider();
var varietacoll = varietaProv.Find(idpart);
this.storeVarieta.DataSource = varietacoll;
this.storeVarieta.DataBind();
}
the method runs correctly, but since the id has no correspondence in the db, I get an empty collection for the detail store.the parameter idpart is correctly sent from the direct method but it is not the record id I expected.
As far as i could understand I thought that if the IDProperty is set, then this is used also as id for the record... is the same id for the gridpanel bound to the store, or am I looking at the wrong property?
All the examples i have seen refer to this property to identify the selected record.
Thanks in advance!
Last edited by lapix; Feb 24, 2012 at 12:21 AM.