Incorrect SelectedItems Property

2 posts, 0 answers
  1. Paul
    Paul avatar
    23 posts
    Member since:
    Sep 2006

    Posted 12 Aug 2011 Link to this post

    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

  2. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 17 Aug 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top