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. Image for the cookie policy date

Numbering always from 1 after filter in Grid

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 :)

4 Replies

HJ Hariharan J V Syncfusion Team 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 



BA Bart 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 :)


BA Bart June 11, 2019 09:18 AM UTC

Any ideas?


HJ Hariharan J V Syncfusion Team 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 


Loader.
Live Chat Icon For mobile
Up arrow icon