PDA

View Full Version : [CLOSED] How to get ID of multiple rows selected from Grid using Selectionmodel



Tonic
May 09, 2013, 5:06 AM
hello..!
i have a gridpanel which contains a check box in front of every row and also on header.
if i select the check box on header it selects all below check box (or all rows in gridpanel )
now in code file it only returns me ID of first row.. but i need ID of all different rows availabe in gridpanel.


code aspx


<ext:GridPanel ID="GridPanel1" runat="server" Width="300" Layout="Fit" StoreID="JobStoreMapping"
Selectable="true" Height="200" AutoScroll="true">
<ColumnModel>
<Columns>
<ext:Column ID="ColPosition" runat="server" DataIndex="posCode" Width="100" Text="POSITION"
Align="Center" />
<ext:Column ID="ColPosName" runat="server" DataIndex="posName" Width="200" Text="POSITION NAME"
Align="Center" />

</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server" Mode="Multi">
<DirectEvents>
<Select OnEvent="Cell_Click" Buffer="100">
<ExtraParams>
<ext:Parameter Name="jobMappIdPk" Value="record.data.pk_jobFamillMapp" Mode="Raw">
</ext:Parameter>
<ext:Parameter Name="jobMappId" Value="record.data.jobFamilyId" Mode="Raw">
</ext:Parameter>
<ext:Parameter Name="ShortDesc" Value="record.data.jfmlyShortDesc" Mode="Raw">
</ext:Parameter>
<ext:Parameter Name="PositionId" Value="record.data.fk_PositionId" Mode="Raw">
</ext:Parameter>
</ExtraParams>
</Select>
</DirectEvents>
</ext:CheckboxSelectionModel>

</SelectionModel>
</ext:GridPanel>

code behind


protected void Cell_Click(object sender, DirectEventArgs e)
{
// Function to respond when the user clicks on an entry in Job Family list on the Grid.
try
{


string jobMappIdPk = e.ExtraParams["jobMappIdPk"]; // get the row id of the Job Family selected from the grid. This rowid is same as the key for the
// Job Family Table.
Session["jobMappIdPk"] = jobMappIdPk; // Save this jobId. We need this information throughout the operation.
// Short Description of the Job
TAJobDesc.Text = e.ExtraParams["ShortDesc"]; // Long Description
// DDJobFamily1.Text = e.ExtraParams["PositionId"]; // Status: Active/Inactive/Draft
// Now that user selected a job family, we can enable the following buttons.
this.btnSave.Hide();
this.btnNew.Disable();
this.btnDel.Enable();
this.btnClosePos.Hide();
this.btnCancel.Show();
}
catch (Exception ex)
{
X.Msg.Alert("Status", ex.Message, new JFunction { Fn = "" }).Show();
}
}


i am using Session["jobMappIdPk"] in where clause to perform delete action in sql...
but unfortunately it store ID of nly first row..
plz help me ...

example query is:-


delete from tc_jobFamilyMapping where pk_jobFamillMapp = '" + Session["jobMappIdPk"]+ "'

Daniil
May 09, 2013, 5:20 AM
Hi @Tonic,

Please use a selection model's SelectedRows property.
http://examples2.ext.net/#/GridPanel/Selection_Models/Checkbox_Selection/

Tonic
May 09, 2013, 6:16 AM
thanks ...! done....