We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can't copy selected rows on treegrid

Thread ID:





127968 Dec 22,2016 07:45 AM UTC Dec 27,2016 05:28 PM UTC ASP.NET MVC 3
Tags: TreeGrid
Mohamed Salah
Asked On December 22, 2016 07:45 AM UTC

I want to copy selected rows on treegrid 

Mahalakshmi Karthikeyan [Syncfusion]
Replied On December 23, 2016 11:13 AM UTC

Hi Salah, 
Thanks for contacting Syncfusion support. 
We can get the selected row details in the RowSelected event arugments. Please find the following code example for details. 
.ClientSideEvents(co => { co.RowSelected("rowSelected"); }) 
<script type="text/javascript"> 
        function rowSelected(args) { 
            //you can get the selected row data here. 
            var selectedItem = args.data.item; 
You can also use Row Drag And Drop feature to change the position of rows in TreeGrid. Please find the below code example to enable row drag and drop. 
Can you please share us more details about your requirement to serve you better? Please share us the purpose of copying particular row in TreeGrid. 
Mahalakshmi K. 

Mohamed Salah
Replied On December 23, 2016 06:09 PM UTC

I want to copy selected rows to excel file

Jonesherine Stephen [Syncfusion]
Replied On December 27, 2016 05:28 PM UTC

Hi Salah, 
Please find the response below 
1. We have rendered the Tree Grid with check box. 
2. On button click action we have converted the selected records to paste-able format in excel and copied this text in clipboard. 
3. Now we can paste the copied records in a excel file.  
Please find the code example below: 
<button onclick="clickme()">Click</button> 
    <textarea id="txtarea1" style="display:none;"></textarea> 
function clickme() { 
        //copy text to clipboard 
        function copyTextArea() { 
        if (document.queryCommandSupported && document.queryCommandSupported("copy")) { 
                //To get the checked records 
var txt = selectedItemText($("#TreeGridContainer").ejTreeGrid("model.selectedItems")); 
                $("#txtarea1").val(txt).css("display", "block").select(); 
                try { 
                    return document.execCommand("copy"); 
                } catch (ex) { 
                    console.warn("Copy process failed.", ex); 
                    return false; 
                } finally { 
                    $("#txtarea1").css("display", "none"); 
        //Genarate text to be copied in clipboard 
        function selectedItemText(records) { 
            var completeText = "", 
                columns = $("#TreeGridContainer").ejTreeGrid("instance").model.columns; 
            for (var count = 0; count < records.length; count++) { 
                for (var columnCount = 0; columnCount < columns.length; columnCount++) { 
                    if (columns[columnCount]["visible"]) { 
           if (!ej.isNullOrUndefined(records[count][columns[columnCount]["field"]])) 
                 completeText += (records[count][columns[columnCount]["field"]]); 
                        if (columnCount != columns.length - 1) 
                            completeText += " \t"; 
                completeText += "\n"; 
            return completeText; 
We have also prepared the sample based on this, please find the sample from below location. 
Jone sherine P S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon