lorenzofox3 / Smart-Table

Code source of Smart Table module: a table/grid for Angularjs
http://lorenzofox3.github.io/smart-table-website/
1.8k stars 513 forks source link

Pagination sets to start when collection changes #797

Closed sak0407 closed 6 years ago

sak0407 commented 6 years ago

Hello contributor !

Please before you submit your issue, make sure all the below can be checked (note if anything is expected, you can simply add it under the relevant checkbox)

Note that it not all the above checkbox can be marked as checked the issue will immediately be closed. Thanks for your understanding.

And don't forget to close you issue when it is solved !

Thanks again for your contribution. Angular 1.3 smart table 2 .1

Hi, I am new in angular, In my application i am using smart table, its very exciting table directives, i am able to get working every thing.

But recently i am facing one issue, in my table hvng 1000 records, so with pagination if i select number 5 page, and edit something its coming back to first page.

I know this is expected behaviour, but my requirements is bit different, i want that page stays on same page . can i get any working code ,so that i can implement. Thanks in advance.

sak0407 commented 6 years ago

I checked issue 581 , but it didn't help me, i didnt able to implement, if anyone help me by sharing code snippet, it will help me.

MrWook commented 6 years ago

Hello @sak0407,

do you use the pipeline or just a plain array and do you use st-safe-src?

But anyway you could transfer the row index to your function and after you edited the data you can edit the row instead of reloading the whole data kind of like this:

function save(row_edit){
        //do your stuff here......

        //update just the row
    for(var i = 0; i < $scope.displayed.length; i++){
        if($scope.displayed[i][11] == row_edit.id){
            $scope.displayed[i][0] = row_edit.model.firstname;
            $scope.displayed[i][1] = row_edit.model.lastname;
            $scope.displayed[i][2] = row_edit.model.age;
            break;
        }
    }
}