Problem while restricting Add New Record button in BatchEdit RadGrid

2 posts, 0 answers
  1. Sandeep
    Sandeep avatar
    6 posts
    Member since:
    Apr 2016

    Posted 09 May 2016 Link to this post

    Hi Telerik Team,
    I am using batch edit grid.

    My requirement: I want to restrict the user to add new records when the number of records in grid view is more than the Some Quantity (Eg:-2 records).
    Below is the code

    Note:-Quantity is dynamically Vairing value


    <telerik:RadGrid ID="gvSerialNumberTracking" GridLines="None" runat="server" AllowPaging="false"OnBatchEditCommand="gvSerialNumberTracking_BatchEditCommand" OnItemCommand="gvSerialNumberTracking_ItemCommand" CssClass="gvPLC">
    <MasterTableView DataKeyNames="SerialNumber_ID,SerialNumber_DJ_ID" TableLayout="Auto" EditMode="Batch" AutoGenerateColumns="false"CommandItemDisplay="Top" ClientDataKeyNames="SerialNumber_ID">
     <BatchEditingSettingsEditType="Row" />                                                                     
    <telerik:GridBoundColumn DataField="UnitSN" HeaderText="Unit SN" HeaderStyle-Width="100px" UniqueName="UnitSN"></telerik:GridBoundColumn>
    <telerik:GridBoundColumnDataField="Sub1" HeaderText="Sub1" HeaderStyle-Width="100px" UniqueName="Sub1"></telerik:GridBoundColumn
     <telerik:GridBoundColumnDataField="Sub2" HeaderText="Sub2" HeaderStyle-Width="100px" UniqueName="Sub2"></telerik:GridBoundColumn>
    <ClientSettings AllowKeyboardNavigation="true">
    <ClientEvents  OnRowCreating ="OnRowCreating" />


    function OnRowCreating(sender, args)
    var grid = $find("<%=gvSerialNumberTracking.ClientID %>");
    var MasterTable = grid.get_masterTableView();
    var Rows = MasterTable.get_dataItems();
    var Qty = $("#txtJQuantity").val()
    // txtJQuantity is the quantity (in our case its 2)
    if ((Rows.length) > ($("#txtJQuantity").val()))
    //alert('Wait! You cannot add more than ' + $("#txtJQuantity").val() + ' items');

    Thanks and Regards,
  2. Eyup
    Eyup avatar
    4072 posts

    Posted 11 May 2016 Link to this post

    Hi Sandeep,

    I've already replied to your query in the following thread:

    I recommend following the suggested action there.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top