radgrid EnableDragToSelectRows serverside

5 posts, 0 answers
  1. Lukrs
    Lukrs avatar
    39 posts
    Member since:
    Sep 2012

    Posted 26 Feb 2009 Link to this post

    Hi,

    I'm trying to select rows and handle them serverside. I would like to trigger a postback on multiple row selecting by drag. I managed to do a postback with this code :

    function RowSelected(row, eventArgs) {
            alert(row);
            __doPostBack('<%=skupineGrid.ClientID %>');

        }


    It is triggered here <ClientEvents OnRowSelected="RowSelected" />.

    Now I would like to do an update in the database for selected rows.

     foreach (GridDataItem item in skupineGrid.SelectedItems)
            {
              item.Selected = true;
              // bla bla
            }

    How can I achive this?




  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Feb 2009 Link to this post

    Hi,

    Try accessing the selected rows in the Prerender event of the Grid.

    CS:
    protected void RadGrid1_PreRender(object sender, EventArgs e) 
        { 
            foreach (GridDataItem dataitem in RadGrid1.SelectedItems) 
            { 
                
            } 
          
        } 


    Shinu



  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lukrs
    Lukrs avatar
    39 posts
    Member since:
    Sep 2012

    Posted 27 Feb 2009 Link to this post

    Hi,

    This doesn't work.

    The codebehind in preRender doesn't get SelectedItems.


    LP, Luka
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Feb 2009 Link to this post

    Hi Luka,

    Give a try with the following code snippet in the PreRender event and see whether it works

    CS:
       protected void RadGrid1_PreRender(object sender, EventArgs e) 
        { 
            foreach (GridDataItem dataitem in RadGrid1.MasterTableView.Items) 
            { 
                if (dataitem.Selected) 
                {  
                 // access the selected items here
                } 
            } 
       } 

    Thanks
    Princy



  6. Lukrs
    Lukrs avatar
    39 posts
    Member since:
    Sep 2012

    Posted 27 Feb 2009 Link to this post

    Hi Princy,

    I think we do not understand each other quite right.

    The thing is:

    I call this javascript function on client side <ClientEvents OnRowSelected="RowSelected" />

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
    <script type="text/javascript">
        function RowSelected(row, eventArgs) {
            alert(row);
            __doPostBack('<%=skupineGrid.ClientID %>');

        }
    </script>
         </telerik:RadCodeBlock>



    I click on a row, or select multiple rows with <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" /> property set to true.

    The postback is triggered, but on preRender (protected void RadGrid1_PreRender(object sender, EventArgs e) ) there are no selected items.

    Basicly my idea is to select rows clientside, and maintain selected rows after postback. I found tutorials that have a button, which postbacs and the rows stay selected. With my javascript I posted, RowSelected, this simply doesn't happen.

    Any Ideas why?

    thanks,
    LP, Luka


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