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

[Solved] Copy data of one row into another row

4 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nancy
Top achievements
Rank 1
Nancy asked on 26 Dec 2012, 10:17 AM
Hello
I want to copy data of one row into another when clicked on custom command button. However, i am able to get new blank row to open up when clicked on custom button but how can i load the data of the row having custom button into newly opened row. Any help will be appreciated.

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 26 Dec 2012, 01:19 PM
Hi Nancy,


Basically this feature is not supported - I would suggest upgrade to KendoUI where it can be achieved using simple JavaScript code.


Kind Regards,
Vladimir Iliev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Nancy
Top achievements
Rank 1
answered on 27 Dec 2012, 08:31 AM
Hello Vladimir Iliev 

Thnx for the reply. But isn't there any other way this functionality can be achieved? Since i am using Telerik Grid there is no point using KendoUI. Do let me know if there is any alternative way this can be accomplished. 


0
Vladimir Iliev
Telerik team
answered on 27 Dec 2012, 08:54 AM
Hi Nancy,

 
Basically you can extend the new model with the currently selected grid row model, make the ID equal to the default value and use the insertRow method to create the new record:

<button id="copy" onclick="CopyRow()"> copy </button>
 
<script type="text/javascript">
    function CopyRow() {
        //Replace 'Grid' with your grid name
        var grid = $('#Grid').data("tGrid");
        var selectedRow = grid.$tbody.find(".t-state-selected");
        
        if (selectedRow.length) {
            var item = grid.dataItem(selectedRow);
 
            var newModel = {};
            $.extend(newModel, item);
            //Replace ProductID with your model ID
            newModel.ProductID = 0; //make the ID the default value
            grid.insertRow(newModel);
        }
    }
</script>

Kind Regards,
Vladimir Iliev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Nancy
Top achievements
Rank 1
answered on 27 Dec 2012, 10:17 AM
Do ID need to set to 0 value?
Tags
Grid
Asked by
Nancy
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Nancy
Top achievements
Rank 1
Share this question
or