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

Search a specific row

Thread ID:

Created:

Updated:

Platform:

Replies:

141023 Nov 19,2018 05:04 PM UTC Nov 20,2018 07:25 AM UTC JavaScript 1
loading
Tags: ejGrid
Luis Carlos
Asked On November 19, 2018 05:04 PM UTC

Good evening.

I would like to select the row with Customer ID = "WANDK",  when I render it, as you can see in the below image.

 

How can I find the Customer ID "WANDK"? and how can I go to this page and select it?

I will be awaiting for your reply, thank you in advance.

Regards, Luis Carlos.

Vignesh Natarajan [Syncfusion]
Replied On November 20, 2018 07:25 AM UTC

Hi Luis, 
 
Thanks for using Syncfusion products. 
 
Query: “search specific row 
 
From your query, we understood that you need to search a record and navigate to that page and select that record during the initial rendering itself. We have achieved your requirement using dataBound event gotoPage  and selectRows method  of ejGrid.   
 
Refer the below code example 
 
$(function () { 
            $("#Grid").ejGrid({ 
                // the datasource "window.gridData" is referred from jsondata.min.js 
                dataSource: window.gridData, 
                allowPaging: true, 
                dataBound: function(args){ 
                 var rowIndex = args.model.dataSource.findIndex(x=>x.CustomerID == "WANDK"); //find the index of the value from dataSource 
                 var page = rowIndex / this.model.pageSettings.pageSize;  // calculate its page number 
                 if(page > 1) 
                   this.gotoPage(Math.ceil(page)); // navigate to that page 
                 this.selectRows(rowIndex % this.model.pageSettings.pageSize); // selcet the record using its index 
                }, 
                columns: [ 
.                         .                  .                    .                      .                     .                      .  
                ] 
            }); 
               }); 
 
From the dataSource we have found that index of the particular record and found the page using that value. We have navigated to that page using gotoPage() method and selected the row using selectRows() method 
 
For your convenience we have prepared a JS playground sample  
 
 
Refer our API documentation for your reference 
 
  
 
 
 
Note: provided solution will work only for local data, if you are using remote data or adaptor please get back to us more details regarding your dataSource. 
 
 
Regards, 
Vignesh Natarajan 
 
 


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.

Please sign in to access our forum

This page will automatically be redirected to the 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

;