PDA

View Full Version : [CLOSED] How to pass record data from a button in a grid toolbar to code behind?



feanor91
Apr 27, 2012, 12:35 PM
Hello

In this toolbar which is a grid toolbar :



<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button ID="btnAddOSA" runat="server" Text="Add" Icon="Add">
<Listeners>
<Click Fn="addNewRecord" />
</Listeners>
<DirectEvents>
<Click OnEvent="TestRecordExists">
<ExtraParams>
<ext:Parameter Name="Entity" Value="#{cboEntityOSA}.getValue()" Mode="Raw" Encode="false"></ext:Parameter>
<ext:Parameter Name="Year" Value="#{cboYearOSA}.getValue()" Mode="Raw" Encode="false"></ext:Parameter>
<ext:Parameter Name="Month" Value="#{cboMonthOSA}.getValue()" Mode="Raw" Encode="false"></ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="btnDelOSAData" runat="server" Text="Remove" Icon="Delete">
<DirectEvents>
<Click OnEvent="DelData">
<ExtraParams>
<ext:Parameter Name="data" Value="#{grdOSA}.getRowsValues({selectedOnly : true})" Mode="Raw" Encode="true"></ext:Parameter>
</ExtraParams>
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>


How can I pass the record.data to the code behind function "TestRecordExists"?

Daniil
Apr 27, 2012, 1:35 PM
Hi,

The record which is just added by "addNewRecord"?

What is the addNewRecord code?

feanor91
Apr 27, 2012, 1:43 PM
var addNewRecord = function ()
{

var DAT_Today = new Date();
var INT_CurrentMonth = DAT_Today.getMonth();
var INT_CurrentYear = DAT_Today.getFullYear();
var STR_MonthToEnter = "";

switch ( INT_CurrentMonth )
{
case 0: //January
STR_MonthToEnter = "December"
INT_CurrentYear = INT_CurrentYear - 1;
break;
case 1: //February
STR_MonthToEnter = "January"
break;
case 2: //March
STR_MonthToEnter = "February"
break;
case 3: //April
STR_MonthToEnter = "March"
break;
case 4: //May
STR_MonthToEnter = "April"
break;
case 5: //June
STR_MonthToEnter = "May"
break;
case 6: //July
STR_MonthToEnter = "June"
break;
case 7: //August
STR_MonthToEnter = "July"
break;
case 8: //September
STR_MonthToEnter = "August"
break;
case 9: //October
STR_MonthToEnter = "September"
break;
case 10: //November
STR_MonthToEnter = "October"
break;
case 11: //December
STR_MonthToEnter = "November"
break;
}

var gridName = this.id.substr( 6 );
var grid = Ext.getCmp( "grd" + gridName );

grid.editingPlugin.cancelEdit();

switch ( gridName )
{
case "WorldRegion":
grid.store.insert( 0, {
STR_NameWorldRegion: "New region name"
} );
break;
case "Country":
grid.store.insert( 0, {
STR_CountryName: "New country"
} );
break;
case "Template":
grid.store.insert( 0, {
STR_Template: "New template name",
STR_ChartsInTemplate: "",
BOOL_Private: false,
INT_idUser: 0
} );
break;
case "Entities":
grid.store.insert( 0, {
STR_EntityName: "New entity"
} );
break;
case "OSA":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_OSA_Repair: 0,
DEC_OSA_ETTR: 0,
DEC_OSA_ETFQ: 0,
DEC_OSA_RepairCost: 0,
DEC_OSA_StockOut: 0,
DEC_OSA_OOBF: 0,
DEC_OSA_Calls: 0,
DEC_OSA_Emails: 0,
DEC_OSA_Letters: 0,
DEC_OSA_Fax: 0
} );
break;
case "MASK":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_MASK_Repair: 0,
DEC_MASK_ETTR: 0,
DEC_MASK_ETFQ: 0,
DEC_MASK_RepairCost: 0,
DEC_MASK_StockOut: 0,
DEC_MASK_OOBF: 0,
DEC_MASK_Calls: 0,
DEC_MASK_Emails: 0,
DEC_MASK_Letters: 0,
DEC_MASK_Fax: 0
} );
break;
case "VEN":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_VEN_Repair: 0,
DEC_VEN_ETTR: 0,
DEC_VEN_ETFQ: 0,
DEC_VEN_RepairCost: 0,
DEC_VEN_StockOut: 0,
DEC_VEN_OOBF: 0,
DEC_VEN_Calls: 0,
DEC_VEN_Emails: 0,
DEC_VEN_Letters: 0,
DEC_VEN_Fax: 0
} );
break;
case "TPP":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_TPP_Repair: 0,
DEC_TPP_ETTR: 0,
DEC_TPP_ETFQ: 0,
DEC_TPP_RepairCost: 0,
DEC_TPP_StockOut: 0,
DEC_TPP_OOBF: 0,
DEC_TPP_Calls: 0,
DEC_TPP_Emails: 0,
DEC_TPP_Letters: 0,
DEC_TPP_Fax: 0
} );
break;
case "ATS":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_ATS_Repair: 0,
DEC_ATS_Loans: 0,
DEC_ATS_DeviceExchange: 0,
DEC_ATS_DeviceInvestigated: 0
} );
break;
case "TRS":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_TRS_RegularMaintenance: 0,
DEC_TRS_WarrantyRepair: 0,
DEC_TRS_NonWarrantyRepair: 0
} );
break;
case "PS":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_PS_S7: 0,
DEC_PS_S8: 0,
DEC_PS_S9: 0,
DEC_PS_CS: 0,
DEC_PS_VPAP: 0,
DEC_PS_Stellar: 0,
DEC_PS_EoleHelia: 0,
DEC_PS_VS: 0,
DEC_PS_Elisee: 0
} );
break;
case "FCC":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_FCC_AbandonRate: 0,
DEC_FCC_FirstCallResolution: 0,
DEC_FCC_CostPerContact: 0,
DEC_FCC_Occupancy: 0,
DEC_FCC_AverageHandleTime: 0,
DEC_FCC_AverageSecondsToAnswer: 0
} );
break;
case "LO_OM":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_LO_OM_Orders: 0,
DEC_LO_OM_OrdersLines: 0,
DEC_LO_OM_AveOrders: 0,
DEC_LO_OM_ParcelsStandards: 0,
DEC_LO_OM_ParcelsExpress: 0
} );
break;
case "LO_AVA":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_LO_AVA_BackOrders: 0,
DEC_LO_AVA_BackOrderValue: 0,
DEC_LO_AVA_FirstDelivery: 0,
DEC_LO_AVA_SecondDelivery: 0,
DEC_LO_AVA_ThirdDelivery: 0,
DEC_LO_AVA_FourthDelivery: 0,
DEC_LO_AVA_PDBackOrderQuantity: 0,
DEC_LO_AVA_PDBackOrderOrderLines: 0
} );
break;
case "FI":
grid.store.insert( 0, {
INT_idKPIs: 0,
INT_idWorldRegion: 0,
INT_idCountry: 0,
INT_idRmdEntities: 0,
INT_idUsers: 0,
STR_CountryName: "",
STR_nameWorldRegion: "",
STR_EntityName: "",
INT_Year_KPIs: INT_CurrentYear,
STR_Month_KPIs: STR_MonthToEnter,
DEC_FI_WarehouseCosts: 0,
DEC_FI_TransportCosts: 0,
DEC_FI_InventoryDays: 0,
DEC_FI_InventoryValue: 0
} );
break;
}

grid.getView().refresh();
grid.editingPlugin.startEdit( 0, 0 );
};

Daniil
Apr 27, 2012, 2:02 PM
The currently edited record you can get this way.

grid.editingPlugin.context.record

So, the answer is:

<ext:Parameter
Name="data"
Value="#{GridPanel1}.editingPlugin.context.record.data"
Mode="Raw"
Encode="true" />

feanor91
Apr 27, 2012, 2:07 PM
Thansk a lot.