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

Delete row

2 Answers 228 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 17 Mar 2010, 12:00 PM

Hi Everyone

I'm having an issue deleting a row in the radgrid.  I have gone through the samples, but they don't help...

My javaScript for the delete (which happens on 'RowSelect') is:

function RowSelected(sender, args) {

var DocumentManagementID = args.getDataKeyValue("DocumentManagementID");
var SCID = args.getDataKeyValue("SCID");
var table = sender.get_masterTableView().get_element();
var currentRowIndex = args.get_gridDataItem().get_element().rowIndex;
var row = table.rows[currentRowIndex];
table.deleteRow(currentRowIndex);
var tURL = 'frmSingleCapture_SupervisorVerification_ViewApp.aspx?DocumentManagementID=' + DocumentManagementID + '&SCID=' + SCID + '&SC=Yes'
window.open(tURL);

}

if you add alerts to the various var declarations, they all return items (table returns an [object] message) until current row.

agrs.get_gridDataItem() is null and the currentRowIndex therefore does not populate...

What am i doing wrong?

My grid itself looks as follows:

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="dsApproveCapture" GridLines="None" Skin="Sunset">
 <ClientSettings>
  <Selecting AllowRowSelect="true" />
  <Scrolling AllowScroll="true" />
  <ClientEvents OnRowSelected="RowSelected" />
 </ClientSettings>
 <PagerStyle Mode="Advanced" />
 <MasterTableView DataKeyNames="DocumentManagementID" DataSourceID="dsApproveCapture" ClientDataKeyNames="DocumentManagementID, SCID">
  <RowIndicatorColumn>
   <HeaderStyle Width="20px"></HeaderStyle>
  </RowIndicatorColumn>
  <ExpandCollapseColumn>
   <HeaderStyle Width="20px"></HeaderStyle>
  </ExpandCollapseColumn>
  <Columns>
   <telerik:GridBoundColumn DataField="DocumentManagementID" DataType="System.Int32" HeaderText="Doc ID" ReadOnly="True" SortExpression="DocumentManagementID" UniqueName="DocumentManagementID">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="SCID" DataType="System.Int32" HeaderText="Capture ID" ReadOnly="True" SortExpression="SCID" UniqueName="SCID">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="FirstInsertedDate" DataType="System.DateTime" HeaderText="First inserted date" SortExpression="FirstInsertedDate" UniqueName="FirstInsertedDate" DataFormatString="{0:dd MMM yyyy, HH:mm:ss}">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="SchemeName" HeaderText="Scheme name" SortExpression="SchemeName" UniqueName="SchemeName">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="ApplicationReference" HeaderText="Application reference" SortExpression="ApplicationReference" UniqueName="ApplicationReference">
   </telerik:GridBoundColumn>
   <telerik:GridBoundColumn DataField="FullName" HeaderText="Capturer" SortExpression="FullName" UniqueName="FullName">
   </telerik:GridBoundColumn>
  </Columns>
 </MasterTableView>
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Mar 2010, 01:29 PM
Hello Mark,

The args.get_gridDataItem() is not directly available on the client unless OnRowCreating/OnRowCreated events are hooked up. So attach any of these events to radgrid and try your code to delete the row.

ASPX:
 . . .
 
</MasterTableView> 
      <ClientSettings>  
           <Selecting AllowRowSelect="true" /> 
           <ClientEvents OnRowCreated="OnRowCreated" OnRowSelected="RowSelected"/>  
      </ClientSettings>
   . . .

JavaScript:
 
function RowSelected(sender, args)   
{  
  var DocumentManagementID = args.getDataKeyValue("DocumentManagementID");  
  var SCID = args.getDataKeyValue("SCID");  
  var table = sender.get_masterTableView().get_element();  
  var currentRowIndex = args.get_gridDataItem().get_element().rowIndex;  
  var row = table.rows[currentRowIndex];  
  table.deleteRow(currentRowIndex);   
function OnRowCreated() 
 

Hope this helps :)
Shinu.
0
Mark
Top achievements
Rank 1
answered on 17 Mar 2010, 02:03 PM
thanks man - she works :)  I really appriciate it!
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or