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

BatchEditing Error !

1 Answer 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phong
Top achievements
Rank 1
Phong asked on 08 Jun 2016, 04:40 AM

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.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 13 Jun 2016, 05:42 AM
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.
Tags
Grid
Asked by
Phong
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or