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

[Solved] RadGrid row selected parameters passed to a RadWindow

3 Answers 368 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott MacDonald
Top achievements
Rank 1
Scott MacDonald asked on 23 Apr 2009, 06:40 PM
I allow my users to select one or more rows from my grid and drag them to an html element. The html element recognizes the drag and drop of rows, but I an not able to figure out how to determine which rows were selected to pass the row identifiers to the radwindwow for processing. Thoughts?

function

 

onRowDropping(sender, args) {

 

 

  var node = args.get_destinationHtmlElement();

 

 

  if (isChildOf('outSend', node)) {

 

 

     if (confirm("Would you like to proof your message and send out these ...?")) {

 

       args.set_destinationHtmlElement($get(

'outSend'));var CRS = args.get_owner().get_gridDataItem().get_dataItem()["CrsID"]

 

 

       var oManager = GetRadWindowManager();

 

 

       var CrsID = 7499; // I am passing an ID to radwindow and this works fine, but actually need to collect this from the radgrid

 

       oManager.open(

"../user/outsend.aspx?IDS=" + CrsID, "RadW1");

 

       }

 

     else

 

       args.set_cancel(

true);

 

    }

  }

}




 

<telerik:RadGrid ID="courseContent" runat="server" Width="273" ItemStyle-Wrap="true"

 

 

Height="300" AllowMultiRowSelection="true" AllowMultiRowEdit="true" gridlines="None"

 

 

Skin="WebBlue" OnNeedDataSource="courseContent_NeedDataSource" AllowAutomaticDeletes="true" OnDeleteCommand="courseContent_DeleteCommand">

 

 

<MasterTableView DataKeyNames="CrsID" CommandItemDisplay="None" HorizontalAlign="Center"

 

 

HeaderStyle-BorderWidth="0" ItemStyle-BorderWidth="0" FooterStyle-BorderWidth="0"

 

 

AutoGenerateColumns="False" Width="100%" BorderWidth="0">

 

 

<Columns>

 

 

<telerik:GridBoundColumn UniqueName="crsid" datafield="crsid" Visible="false"></telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn HeaderStyle-Font-Size="8" HeaderText="Current Student Profile Contents" UniqueName="crsNumber">

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblCourseNumber" ForeColor="#333333" Font-Names="arial" Font-Size="9" Text='<%# Databinder.Eval(Container.DataItem,"crsnumber")%>'

 

 

Width="225px" runat="server" BorderWidth="0">

 

 

</asp:Label>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="../skins/webblue/grid/cancel.gif"

 

 

CommandName="Delete" ConfirmText="Are you sure you want to delete the selected row?">

 

 

</telerik:GridButtonColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

<ClientSettings AllowRowsDragDrop="True" >

 

 

<Selecting AllowRowSelect="True" EnableDragToSelectRows="true"/>

 

 

<ClientEvents OnRowDropping="onRowDropping" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Apr 2009, 11:45 AM
Hi Scott,

Try out the following client side code and see whether it helps. I tried an array for storing the selected items customer Id and passed to the RadWindow.

[javascript]
 
<script type="text/javascript">  
function OnRowDropping(sender, args) 
    alert("Dropped target element id is: " + args.get_destinationHtmlElement().id); 
    var node = args.get_destinationHtmlElement(); 
    if (confirm("Would you like to proof your message and send out these ...?"))  
    { 
      var i =0; 
      args.set_destinationHtmlElement($get('outSend')); 
      var items = args.get_draggedItems(); 
      var numberofItems = items.length;       
      var MasterTable = $find("<%=RadGrid1.ClientID %>").get_masterTableView(); 
      var myArray = new Array();  // For storing the selected items particular column value  
      for(i=0; i<numberofItems; i++) 
      {       
           var row = MasterTable.get_dataItems()[items[i]._itemIndexHierarchical]; 
           var cell = MasterTable.getCellByColumnUniqueName(row, "CategoryID");            
           myArray[i] = cell.innerHTML;            
      } 
       var oManager = GetRadWindowManager();        
       oManager.open("Window_for_Drop.aspx?IDS=" + myArray, "RadW1"); 
 
    } 
    else 
       args.set_cancel(true); 
function OnGridCreated() 
 
</script> 

Thanks
Shinu.
0
Scott MacDonald
Top achievements
Rank 1
answered on 24 Apr 2009, 04:46 PM
Thank you Shinu

 When I drag and drop I get the message "innerHTML is null or not an object". It seems the JavaScript can not read from the Grid.

I created a ticket and copied code up to generate this, any thoughts?

Ticket ID is : 207917
0
Yavor
Telerik team
answered on 27 Apr 2009, 02:19 PM
Hello Scott,

To avoid duplicate posts, we can continue our communication in the support ticket that you have opened on the matter.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Scott MacDonald
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Scott MacDonald
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or