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

Selecting rows

Thread ID:

Created:

Updated:

Platform:

Replies:

121920 Feb 9,2016 08:57 AM UTC Mar 4,2016 05:32 AM UTC ASP.NET Web Forms 10
loading
Tags: TreeGrid
Jorge Pampin
Asked On February 9, 2016 08:57 AM UTC

Hello,

How to select a row by javascript based on a value of the row (instead of the index)?

Thans!

Jayakumar Duraisamy [Syncfusion]
Replied On February 10, 2016 11:58 AM UTC

Hi Jorge,


Query: How to select a row by JavaScript based on a value of the row (instead of the index)?


Solution: We can select a row dynamically by using the value of the row as per following code snippet.


<div>

        Enter TaskName to Select:<input type="text" id="searchrow" />

        <input type="button" value="ClickMe" onclick="clickMe();" />

</div>

<ej:TreeGrid ID="Treegrid" runat="server"


….

</ ej:TreeGrid>


<script type="text/javascript">

            function clickMe() {


                var obj = $("#Treegrid").data("ejTreeGrid"),

                model = obj.model,

                searchItem = document.getElementById('searchrow').value,

                currentViewData = model.currentViewData,

                index;              

                for (var count = 0; count <= Object.keys(currentViewData).length; count++)

                {

                    if (currentViewData[count].item.Name != searchItem)

                        continue;

                    index = currentViewData[count].index;

                    break;

                }

                obj.selectRows(index);

            }

          </script>


We have also prepared a sample for your reference. Please find the sample in the following URL.
Sample:  http://www.syncfusion.com/downloads/support/forum/121920/ze/TreeGridSample_ASP.net2045015384
Please let us know if you require further assistance on this.

Regards,
Jayakumar Duraisamy


Jayakumar Duraisamy [Syncfusion]
Replied On February 10, 2016 03:50 PM UTC

Hi Jorge,


Please ignore the previous update.


Query: How to select a row by JavaScript based on a value of the row (instead of the index)?


Solution: We can’t select a row dynamically without index but we can able to find index based on a value of the row.

Please refer the following code snippet.


<div>

        Enter TaskName to Select:<input type="text" id="searchrow" />

        <input type="button" value="ClickMe" onclick="clickMe();" />

</div>

<ej:TreeGrid ID="Treegrid" runat="server"


….

</ ej:TreeGrid>


<script type="text/javascript">

            function clickMe() {


                var obj = $("#Treegrid").data("ejTreeGrid"),

                model = obj.model,

                searchItem = document.getElementById('searchrow').value,

                results = model.updatedRecords,

                index = -1;              

                for (var count = 0; count <= Object.keys(results).length; count++)

                {

                    if (results[count].item.TaskName == searchItem) {

                        index = count;

                        break;

                    }

                }

                obj.option("selectedRowIndex", index);

                obj.updateScrollBar();

            }

        </script>


We have also prepared a sample for your reference. Please find the sample in the following URL.
Sample:  http://www.syncfusion.com/downloads/support/forum/121920/ze/TreeGridSample_ASP.net-2020445848
Please let us know if you require further assistance on this.

Regards,
Jayakumar Duraisamy


Jorge Pampin
Replied On February 11, 2016 06:06 PM UTC

Hello,

And how to select a row at the begining when the control is loaded?

Thanks!

Mahalakshmi Karthikeyan [Syncfusion]
Replied On February 12, 2016 05:13 AM UTC

Hi Jorge,

We can select the row in TreeGrid at load time with the help of “SelectedRowIndex” property based on index numer of the row. Please refer the below code example below for details.

 

<form id="form1" runat="server">

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

</form>

Or if you want to select a row with its value on load time, you can use “Create” client side event as we have done in our previous update. Please refer the below code for details.


<form id="form1" runat="server">

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

     <script type="text/javascript">

             function create() {

                 var obj = this,

                 model = obj.model,

                 searchItem = "Child Task 1",

                 results = model.updatedRecords,

                 index = -1;

                 for (var count = 0; count <= Object.keys(results).length-1; count++)              

                 {

                     if (results[count].item.Name == searchItem) {

                         index = count;

                         break;

                     }

                 }

                 obj.option("selectedRowIndex", index);

                 obj.updateScrollBar();

             }

        </script>

</form>

Here we have manually passed the value and selected the row based on that value.

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

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SelectRows-378673209

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 Gantt control which is available in Essential studio installed location

Regards,

Mahalakshmi K.


Jorge Pampin
Replied On March 1, 2016 10:35 AM UTC

Hello,

And how to select several rows? With selectedRowIndex I only can select a row.

Thanks!

Mahalakshmi Karthikeyan [Syncfusion]
Replied On March 2, 2016 12:25 PM UTC

Hi Jorge,

At Present there is no support to select multiple rows in TreeGrid. So we have logged a feature report regarding this. A support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.

https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents

Please let us know if you require further assistance on this.

Regards,

Mahalakshmi K.


Jorge Pampin
Replied On March 2, 2016 06:06 PM UTC

Hello,

I can't see the incident in my Incidents. Where is it?

Thanks!

Saranya CJ [Syncfusion]
Replied On March 3, 2016 06:06 AM UTC

Hi Jorge,
You can see this last reported query's incident by changing the status to "closed" under "Incidents" after logging into your Direct trac account. We have given feature information and closed the incident. Could you please check and update us?
Regards,
Saranya

Jorge Pampin
Replied On March 3, 2016 08:05 AM UTC

Hello,

I can see it now, thanks!

Saranya CJ [Syncfusion]
Replied On March 4, 2016 05:32 AM UTC

Hi Jorge,
Thank you for your update. Please let us know if you require any other assistance.
Regards,
Saranya

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

;