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

How to create a Row template in TreeGrid?

Platform: ASP.NET Web Forms |
Control: TreeGrid |
Published Date: January 22, 2015 |
Last Revised Date: May 29, 2019

In TreeGrid control, you can customize each row by providing templates or Jsrender script elements. These script elements can be provided as templates for the TreeGrid row using RowTemplateId property. The following is the code example for a simple Jsrender template.

ASP

 <script id="rowTemplateScript" type="text/x-jsrender”>
<tr>
   <td class="border" style='height:30px;'>
         <div>{{:#data['EmployeeID']}}</div>
   </td>
           //..           
</tr>
</script>
   <script id="altRowTemplateScript" type="text/x-jsrender”>
<tr>
   <td class="border" style='height:30px;' />
        <div>{{:#data['EmployeeID']}}</div>
   </td>
           //..           
</tr>
</script>

For providing alternate row style in TreeGrid using templates, the AltRowTemplateId property can be used. The following is the code example for applying templates for ASP TreeGrid rows.

ASPX

<script id="rowTemplateScript" type="text/x-jsrender”>
       <tr>
           <td class="border" style='height:30px;'>
                <div>{{:#data['EmployeeID']}}</div>
           </td>
                   //..           
        </tr>
</script>
<script id="altRowTemplateScript" type="text/x-jsrender”>
       <tr>
           <td class="border" style='height:30px;'>
                <div>{{:#data['EmployeeID']}}</div>
           </td>
                   //..           
        </tr>
</script>
<ej:TreeGrid ID="TreeGridRowTemplate" runat="server” ChildMapping = "Children"
             RowTemplateId="rowTemplateScript" AltRowTemplateId="altRowTemplateScript">
            //..
</ej:TreeGrid>
 [ASPX.CS]
protected void Page_Load(object sender, EventArgs e)
        {
          TaskDetailsCollection TaskCollection = new TaskDetailsCollection();
          this.TreeGridRowTemplate.DataSource = TaskCollection.GetDataSource();
          this.TreeGridRowTemplate.DataBind();             
        }

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
mahfoud
Dec 10, 2015
للاعجاز العلمي حقائق جديدة في إعجاز القرآن الكريم والسنة المطهرة تكبير حجم الخط حجم الخط الإفتراضي تصغير حجم الخط Reply

Please sign in to access our KB

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

Up arrow icon

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