【angularjs】表格选中行定位

版权声明:本文博主原创,部分图片来源网络,侵删致歉,转载标明来源。 https://blog.csdn.net/jing875480512/article/details/88343053

效果:

弹出二级页返回后,仍旧定位到上次选中行

主页js的代码:

1.监控选中的是哪一页

              $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
                  if (!$.isEmptyObject(fromParams)) {
                      getData(self.gridOptions.paginationCurrentPage);
                  }
              })

2.定位选中的是哪一行,写在grid代码中

              self.gridOptions = {
                  isRowSelectable: function (row) { //GridRow 
                      if (selectRows.length > 0) {
                          if (row.entity.ProductOrder == selectRows[0].ProductOrder) {
                              row.grid.api.selection.selectRow(row.entity); // 选中行
                          }
                      }
                      else {
                          row.grid.api.selection.clearSelectedRows(); // 清空选中行
                      }
                  },
              };

3.查完数据显示时,判断是否有页数

              var getData = function (currentPage) {
                  //调用方法查询表格数据
                      if (response.data.length == 0) {
                          $scope.myData = [];
                      }
                      else {
                          mydefaultData = response.data.rows;
                          if (typeof (currentPage) == "undefined") {
                              currentPage = 1;
                          }
                          getPage(currentPage, self.gridOptions.paginationPageSize);
                      }
              }

猜你喜欢

转载自blog.csdn.net/jing875480512/article/details/88343053