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

Numbering always from 1 after filter in Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

144191 Apr 24,2019 09:36 AM UTC Jun 12,2019 09:27 AM UTC ASP.NET MVC - EJ 2 4
loading
Tags: Grid
Bart
Asked On April 24, 2019 09:36 AM UTC

Hi, I have a qestion. Is there any way to numbering records in Grid always from 1 after filter by another column?

Lp     Data2
1          355
2          360
3          362
4          342

After filtering by Data2 column I have:

Lp     Data2
4          342
1          355
2          360    
3          362

I would like to get result like this:

Lp     Data2
1          342
2          355
3          360   
4          362


Regards :)

Hariharan J V [Syncfusion]
Replied On April 25, 2019 09:50 AM UTC

Hi Bart, 
 
Thanks for contacting Syncfusion support. 
 
We suggest you to use Sorting feature for sorting particular columns to ascending/descending order. Please refer the below online sample and demo link. 
 
 
If you to apply soring on grid initial load, please use the following documentation. 
 
Regards,  
Hariharan 


Bart
Replied On June 10, 2019 09:39 AM UTC

Hi, Hariharan J V
thanks for your reply but this is not what I mean. I need catch a sorting event on one column (in my example: Data2) and change numbering in another column (Lp) always from 1..N.

Regards :)

Bart
Replied On June 11, 2019 09:18 AM UTC

Any ideas?

Hariharan J V [Syncfusion]
Replied On June 12, 2019 09:27 AM UTC

Hi Bart, 

We suggest you to use the below logic to achieve this requirement, 

<script type="text/javascript"> 
    var count = 1; 
    var flag = false; 
    var resLen = 0; 
    function actionBegin() { 
        flag = true; 
    } 
 
    function rowDataBound(args) { 
        if (flag || resLen==0) { 
            count = this.pageSettings.currentPage * this.pageSettings.pageSize - this.pageSettings.pageSize + 1; 
            resLen = this.currentViewData.length; 
            flag = false; 
        } 
        args.row.cells[0].innerHTML = count; // Changed the particular column cell value 
        resLen--; 
        count++; 
    } 
</script> 

We have used Grid actionComplete event and rowDataBound event to achieve this requirement. For your convenience, we have created the sample with this requirement and you can find that sample from the below link, 

 
Regards, 
Hariharan 


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

Live Chat Icon For mobile
Live Chat Icon