Delete row

3 posts, 0 answers
  1. Mark
    Mark avatar
    9 posts
    Member since:
    Aug 2012

    Posted 17 Mar 2010 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    9 posts
    Member since:
    Aug 2012

    Posted 17 Mar 2010 Link to this post

    thanks man - she works :)  I really appriciate it!
Back to Top