This is a migrated thread and some comments may be shown as answers.

Incorrect SelectedItems Property

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 12 Aug 2011, 01:56 PM
Hi,

I am using radgrid, with client select enabled, with a client select checkbox, in order to allow multiple rows to be selected.
However, I require a callback when the selection is changed, so that I can check the status of items selected etc.

In order to do this I have the following script linked to the client side OnRowSelected and OnRowDeselected events.
function SelectionChanged(sender, args)
{
  // Refresh by calling RadAjaxManager
  $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest()
}

This creates the callback just fine.
The problem, is that the SelectedItems property of the grid has not been updated with the change just carried out.

Is there a way around this?
Do I need a different event?

thank you

Paul

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 17 Aug 2011, 03:43 PM
Hello Paul,

If you cannot access the items inside the SelectedItems collection, you can easily create your own collection of the selected items. You can keep the ajax request approach and use the following code inside the AjaxRequest event handler:
protected void ram1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
    List<GridDataItem> selectedItems = new List<GridDataItem>();
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        if ((item["SelectColumnUniqueName"].Controls[0] as CheckBox).Checked)
        {
            selectedItems.Add(item);
        }
    }
    //use selectedItems collection
}

I hope this helps.

Kind regards,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or