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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Tree Grid, Need a button on every row, to view the record i.e to navigate to another page.

Thread ID:

Created:

Updated:

Platform:

Replies:

123344 Mar 9,2016 05:47 AM UTC Mar 10,2016 06:55 AM UTC ASP.NET Web Forms 1
loading
Tags: TreeGrid
bharat
Asked On March 9, 2016 05:47 AM UTC


Hey, 


Actually, trying out to add a column called view which contains a View-Button or View-Link for each row. Where clicking on this, need to navigate to another page with the clicked row id. 

Please help me to implement this. 


Thanks 
Bharat Jain  

Mahalakshmi Karthikeyan [Syncfusion]
Replied On March 10, 2016 06:55 AM UTC

Hi Bharat,

Thanks for contacting Syncfusion support.

We can get the view-Button in all the Rows of the TreeGrid control with the help of Column Template. Please refer the below code example for details.

<body>

   <script type="text/x-jsrender" id="ImageColumnScript">

       <button class="imageButton">Get Row Id</button>

   </script>

<ej:TreeGrid ID="Treegrid" runat="server"  //… >

<Columns>

        <ej:TreeGridColumn HeaderText="View" Field="View" IsTemplateColumn="true"        

        TemplateID="ImageColumnScript"/>

</Columns>

//…

</ej:TreeGrid>

<script>

    function Redirect() {

        window.location = "Home.aspx";

    }

    $("#Treegrid").on("click", ".imageButton", function (e) {

        var $tr = $(e.target).closest('tr'),

            treeObj = $("#Treegrid").data("ejTreeGrid"),

            rowIndex = ($tr).index(),

            record = treeObj.model.currentViewData && treeObj.model.currentViewData[rowIndex],

            id = record.Id;

        $.ajax({

            type: 'POST',

            url: 'TreeGridDefault.aspx/RowID',

            data: JSON.stringify({ "id": id }),

            contentType: 'application/json; charset=utf-8',

            dataType: 'json',

            success: function (data) {

                window.location = "Home.aspx";

            }

        });

    });

</script>


[WebMethod]

        public static void RowID(int id)

        {

            TreeGridDefault sam = new TreeGridDefault();

            sam.serverMethod(id);                        

        }

        public void serverMethod(int id)

        {

            Session["id"] = id;          

        }

Here we have maintained clicked row id in the session variable called “id” then we have redirected another page and there we have got the clicked id from the session and alerted the retrieved value in the message box.

We have also prepared a sample based on this and you can find the sample under the following location.

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/PageNavigate-2059951840

Note: We have removed bin and obj folder in the given sample for some security reasons, we must include Syncfusion.EJ and Syncfusion.EJ.Web dlls to render the TreeGrid control which is available in Essential studio installed location    

Regards,

Mahalakshmi K.


CONFIRMATION

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.

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

;