Reputation: 523
I am using Telerik grid in my application. I inserted a GridViewCheckBoxColumn at first column of the grid. The check boxes created successfully but i am not able to check multiple check boxes. I am able to check single checkbox only.
How can i check multiple checkboxes?
And also i want to know that checked row counts in the telerik gridview because i am using collection to bind the data in the GridView. In that collection How shall i get the selected rows?
Please tell me some suggestion to solve these problems
Here is my code
// AvailablePacks is getting all the rows in the grid view
foreach (var pack in AvailablePacks)
{
if (SelectedPack != null)
{
var cachedPack = AvailablePacks.FirstOrDefault(z => z.Casepack.CasePackId == pack.Casepack.CasePackId);
((IList<CasePackPivotRow>)AvailablePacks).Add(SelectedPack );
this.SelectedPacks.Remove(SelectedPack );
}
}
And here is my XAML code for creating check box in gridview:
<telerik:GridViewCheckBoxColumn Header=""
Width="15"
EditTriggers="CellClick"
AutoSelectOnEdit="True"
DataMemberBinding="{Binding Selection, Mode=TwoWay}"/>
What i have to select multiple checkboxes in the grid?
Thanks in Advance.
Upvotes: 1
Views: 1723
Reputation: 2197
telerik said : SOLUTION
In order to implement the desired requirement, first subscribe to the ValueChanged event and then execute the following code snippet in the ValueChanged event handler:
void radGridView1_ValueChanged(object sender, EventArgs e)
{
RadCheckBoxEditor editor = sender as RadCheckBoxEditor;
if (editor != null && (bool)editor.Value == true)
{
this.radGridView1.GridElement.BeginUpdate();
foreach (GridViewDataRowInfo row in this.radGridView1.Rows)
{
if (row != this.radGridView1.CurrentRow)
{
row.Cells["Bool"].Value = false;
}
}
this.radGridView1.GridElement.EndUpdate();
}
}
Upvotes: 3