BatchEditing Error !

2 posts, 0 answers
  1. phong
    phong avatar
    1 posts
    Member since:
    Jun 2016

    Posted 07 Jun Link to this post

    Hi Guys,

    I have used RadGrid with batchupdate. I have datalist, When I choose one item from DataList (Product code, Name, Quantity, Quom..), I want to add a new row into Radgrid and auto fill product code, name, quantity.. that I had chossen from Datalist.

    I have function below:

    I$("[id*=btnAddNewD]").live("click", function () {
                var prdccode = $("[id*=lblPrdcCode]", $(this).closest("table")).html();            
                var prdcname = $(this).parent().parent().parent().find("input[type=hidden]").val();                    
                addNewItem(prdccode, prdcname);
                return false;
            });
            function addNewItem(prdccode, prdcname) {
                var grid = $find('<%=RadGrid1.ClientID%>');
                var grid_master = grid.get_masterTableView()
                var grid_batchmanager = grid.get_batchEditingManager()
                grid_batchmanager.addNewRecord(grid_master);

                var newItem = grid_master.get_dataItems()[0]
                var v_prdccode = newItem.get_cell("PrdcCode");

                var newItem1 = grid_master.get_dataItems()[0]
                var v_prdcname = newItem1.get_cell("MPrdcNme");

                setTimeout(function () {
                    grid.get_batchEditingManager().changeCellValue(v_prdccode, prdccode); => change
                    grid.get_batchEditingManager().changeCellValue(v_prdcname, prdcname); => Not change
                }, 0);                        
            }

    ...but only first column was changed value. please help me. 

    Thanks.

  2. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 12 Jun Link to this post

    Hello Phong,

    When you make the desired selection, you can access the given column of the grid:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/using-the--getitems-getcolumn-and-getcolumnsafe-methods

    Then cast it to GridBoundColumn, GridNumericColumn, etc. and set its DefaultInsertValue property.

    Essentially, Batch editing is different than other modes. You can find a detailed explanation in the following section:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-batch-edit-mode


    Alternatively, you can try using the following event handler to intercept the cell and modify its value:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onbatcheditopened

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top