Aug 03, 2011, 3:45 AM
select new record in gridpanel after insert via ajax & web service
I've search the helps and docs for every combination I can think of and my best efforts suggest the following two bolded lines should work. Most examples of adding a selected record are in serverside. The result returned on success contains the vehicle_id number for the record that was just inserted. I would like to be able to select the record with the new vehicle_id so that when the permitstore.reload it will be able to use the selected vehicle_id to filter and return the new vehicle and its associated permits.
Thank you in advance. Bolshoi Spaceeba (I'll have to find a cyrillic font) Big Thanks
Respectfully,
David C
Thank you in advance. Bolshoi Spaceeba (I'll have to find a cyrillic font) Big Thanks
Respectfully,
David C
var processVehicle = function () {
var vStore = this.<%=VehicleStore.ClientID%>;
var vType = <%=cboVehicleType.ClientID%>.getValue();
var vMake = <%=cboMake.ClientID%>.getValue();
var vModel = <%=cboModel.ClientID%>.getValue();
var vYear = <%=numVehicleYear.ClientID%>.getValue();
var vtState = <%=cboVehicleLicenseState.ClientID%>.getValue();
var vtNumber = <%=txtVehicleLicenseNumber.ClientID%>.getValue();
var gpV = Ext.getCmp("<%=gpVehicles.ClientID%>");
gpV.show();
Ext.net.DirectMethod.request({
url: "/ICS/Services/CUS/VehicleReg.asmx/processVehicle",
cleanRequest: true,
json: true,
params: {
vID: vehicleID,
pID: personID,
vType: vType,
vMake: vMake,
vModel: vModel,
vYear: vYear,
vtState: vtState,
vtNumber: vtNumber
},
success: function (result) {
vStore.reload();
if ((vehicleID == 0) && (result > 0)) {
vehicleID = result;
var rowID = vStore.find('vehicle_id',vehicleID);
gpV.getSelectionModel().selectRow(rowID);
processPermit(vehicleID)
}
}
});
};
gridpanel <ext:Store runat="server" ID="VehicleStore" AutoLoad="false" >
<DirectEventConfig>
<EventMask ShowMask="false" />
</DirectEventConfig>
<Proxy>
<ext:HttpProxy Json="true" Method="POST" Url="/ICS/Services/CUS/VehicleReg.asmx/RefreshVehicles" />
</Proxy>
<Reader>
<ext:JsonReader Root="d">
<Fields>
<ext:RecordField Name="vehicle_id" Mapping="vehicle_id" Type="Int" />
<ext:RecordField Name="type" Mapping="type" Type="String" />
<ext:RecordField Name="make" Mapping="make" Type="String" />
<ext:RecordField Name="model" Mapping="model" Type="String" />
<ext:RecordField Name="year" Mapping="year" Type="String" />
<ext:RecordField Name="state" Mapping="state" Type="String" />
<ext:RecordField Name="license" Mapping="license" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
<BaseParams>
<ext:Parameter Name="person_id" Value="#{hidPersonID}.value" Mode="Raw" />
</BaseParams>
</ext:Store>
<ext:Store runat="server" ID="PermitStore">
<DirectEventConfig>
<EventMask ShowMask="false" />
</DirectEventConfig>
<Proxy>
<ext:HttpProxy Json="true" Method="POST" Url="/ICS/Services/CUS/VehicleReg.asmx/RefreshPermits" />
</Proxy>
<Reader>
<ext:JsonReader Root="d">
<Fields>
<ext:RecordField Name="vehicle_permit_id" Mapping="vehicle_permit_id" Type="Int" />
<ext:RecordField Name="permit_id" Mapping="permit_id" Type="String" />
<ext:RecordField Name="permit_type" Mapping="permit_type" Type="String" />
<ext:RecordField Name="yr_cde" Mapping="yr_cde" Type="String" />
<ext:RecordField Name="start_date" Mapping="start_date" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
<BaseParams>
<ext:Parameter Name="vehicle_id" Value="getIdParameter(#{gpVehicles})" Mode="Raw" />
</BaseParams>
</ext:Store>