Limit number of rows to add to a child/detail grid

2 posts, 1 answers
  1. Michael
    Michael avatar
    11 posts
    Member since:
    Sep 2015

    Posted 22 Sep 2016 Link to this post

    Say I have a master grid with a nested grid defined via a detail template, and that detail grid has popup editing enabled.
    Now, if the master grid has a column with e.g. 'MaxDetailRows' to determine the maximum number of records that can be added in the detail grid - how can I check that the number or rows in the detail grid during editing does not exceed the value held in MaxDetailRows.

    Here is the edit event code I have as a start :

    function onEditDetailGrid(e) {
     
        //get editor window object
        var kendoWindow = e.container.data("kendoWindow");
     
        if (e.model.isNew()) {
     
            // ==> Here I would like to read the master grid's row, and read a column/cellvalue (e.g. 'MaxDetailRows')
                          if (number of rows in the detail grid == MaxDetailRows)

                          {

                                       return false;

                          }

            kendoWindow.setOptions({
                title: "New Detail Record"
            });
        }
         
    }



    Thanks in advance,

    Mike

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3169 posts

    Posted 26 Sep 2016 Link to this post

    Hello Mike,

    You can achieve this requirement using the following approach:
    function detailGridEdit(e) {
        if (e.model.isNew()) {
            var masterRow = e.container.parents(".k-detail-row").prev(".k-master-row").first();
            var item = $("#grid").data('kendoGrid').dataItem(masterRow);
            var value = item.ProductName;
            alert(value);
        }
    }

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top