- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
几周来我一直在顺利地使用 ngTable,现在我面临着一个同时做两件事的奇怪问题:
虽然这两件事单独完成时很容易实现,但当我试图同时实现它们时有点困难。
屏幕:一个选择菜单、一个文本框、一个GO!按钮和一个ngTable。
情况 1: 点击 GO 即可调用 API!按钮。 ng-click="loadTable()"
数据显示在 #userTable
$scope.loadTable = function () {
$scope.filterParam = $scope.admin.selectedFilter;
$scope.textParam = $scope.admin.enteredFilterText;
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10 // count per page
}, {
counts: [],
getData: function ($defer, params) {
$http.get($scope.admin.baseUrl + "/Api/User/GetUsersProjects?strKey=" + $scope.filterParam + "&strValue=" + $scope.textParam).then(function (response) {
$scope.admin.tableData = response.data.Users;
$scope.admin.totalRecords = response.data.TotalRecords;
});
var orderedData = params.sorting() ? $filter('orderBy')($scope.admin.tableData, params.orderBy()) : $scope.admin.tableData;
params.total($scope.admin.totalRecords);
$defer.resolve(orderedData);
}
});
$("#userTable").show();
}
案例 1 出现问题:分页不起作用。
情况 2: 在 init()
方法的 getData:
方法中调用 API,并通过 API 调用传递 pageIndex。
init();
function init() {
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10 // count per page
}, {
counts: [],
getData: function ($defer, params) {
$http.get($scope.admin.baseUrl + "/Api/User/GetUsersProjects?strKey=" + $scope.filterParam + "&strValue=" + $scope.textParam + "&pageIndex=" + params.page()).then(function (response) {
$scope.admin.tableData = response.data.Users;
$scope.admin.totalRecords = response.data.TotalRecords;
});
var orderedData = params.sorting() ? $filter('orderBy')($scope.admin.tableData, params.orderBy()) : $scope.admin.tableData;
params.total($scope.admin.totalRecords);
$defer.resolve(orderedData);
}
});
};
$scope.loadTable = function () {
$scope.filterParam = $scope.admin.selectedFilter;
$scope.textParam = $scope.admin.enteredFilterText;
$scope.tableParams.reload();
$("#userTable").show();
}
案例 2 的问题:我无法刷新更改后的用户输入的表格(如果用户更改其输入并单击 GO!
在表格渲染一次之后)。因为,ngTable
拒绝重新创建tableParams的实例(我不确定这里会发生什么)
API 输出的 JSON 结构:
{
"PageSize": 10,
"TotalRecords": 1,
"Users": [
{
"ID": 12,
"FirstName": "Vibhor",
"LastName": "Dube",
"UserID": "vibhord",
"Email": "vibhord@vibhor.com",
"Phone": "111",
"Fax": "1233243",
"IsActive": true,
"Projects": []
}
]
}
最佳答案
我也遇到了同样的问题。
它是通过这样做来工作的:
$scope.applyFilters = function (x, y, z) {
$scope.tableParams.reload();
};
$scope.getTableData = function($defer, params) {
$http.get(getUrl)
.success(function (response, status) {
if (status==200) {
var data = response._embedded.players;
var orderedData = params.$params.sorting ?
$filter('orderBy')(data, params.orderBy()) :data;
params.total(response.total_items);
$defer.resolve(orderedData);
}
})
};
$scope.tableParams = new ngTableParams({
page: $scope.page_count // show first page
, count: $scope.page_length // count per page
}, {
total: 0, // length of data
counts: [10 ,20 ,50 ,100],
getData: $scope.getTableData
});
getUrl 将根据我们在应用过滤器函数中调用的过滤器而变化
关于jquery - ngTable 重新加载带有服务器端分页的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32434992/
我正在尝试在我的应用程序中使用 ngTable,并且执行以下步骤: 1) 导入 ngTable css 文件 2)导入ngTable.js文件 3)将“ngTable”添加到我的 angular.mo
我需要显示一个 5 列表数据,其中包含 3 列标题,类似于下面的屏幕截图(请忽略带有黄色星号的表正文中的第一列)。 帮我解决下面给出的几个问题。 当我在 thead 中提供显式 header 值以将
我尝试编写一个小而简单的 ngTable 演示,但遇到了问题: 当我尝试将数组放入 ngTable 时,浏览器仅显示表的标题行,而不显示数据。结果如截图所示: 所有代码都在 plunker 中 这是“
我正在尝试在我的应用程序中设置 ngTable,但它不支持按日期过滤,而且我不知道如何实现它。我最初将数据中的日期作为时间戳,这使我能够由于时间戳的增量性质而对列进行正确排序,但显然我无法输入 9 月
我正在尝试仅从具有过滤数据的 ng-table 中选择行。使用以下代码过滤表格行,但即使未显示的行也会被选中: Controller : let sampleData = [{id: 1, name:
我有大量数据,并尝试在 AngularJS 的表格中显示这些数据(带有过滤和排序)。为此,我尝试使用 ng-Table,但是当数据太多(> 1000 行)时,它在远程服务器上开始变慢,当数据太多(>
我在 ng-table 中有一个发票列表,并且希望能够过滤嵌套属性。 json 看起来像这样; [ { id: 1, date: "20/03/2014", no:
我在 ngTable 中使用 groupBy,但现在我需要在表中进一步分组: $scope.tableParams = new ngTableParams({ count: 100,
几周来我一直在顺利地使用 ngTable,现在我面临着一个同时做两件事的奇怪问题: 通过服务器端分页从 API 获取数据。 根据用户输入重新加载表格。 虽然这两件事单独完成时很容易实现,但当我试图同时
我正在尝试使用 ngTable 在 html 上显示数据。 在 html 中,我将所有列都设置为“可排序”。 {{re
我有一个使用 ngTable 的小型 AngularJS 应用程序。该应用程序有多个表格,但其中大部分不需要分页。我正在处理一张需要分页的表格。 当表格呈现时,我知道表格中有相当多的条目(超过 100
我在开始使用 ngtables 时遇到了一些困难。现在,分页是正确的,但我无法进行排序和过滤。定义的初始排序顺序都不起作用有什么建议吗?谢谢 脚本 var app = angular.module('
我的屏幕上有两个表格: (1) {{user.userId}}
我正在尝试使用 ngTableParams 更新我的 ngTable,但只显示第一列。 js代码: var dataset = [ {name: "Hello50", bunny:"Bunny1"
我正在使用 ngTable 并异步加载表,但其中一列正在使用选择过滤器,并且当调用它时,表数据尚未解析。最初我使用本地 JSON 对象测试 ngTable 并且这有效,但现在我不确定如何填充选择。是否
我得到了以下 html。我剪了几列 {{pilot.license}}
在我的小型 AngularJS 应用程序中,我使用 ngTable 库渲染了几个表格。只有一个人可以使用分页。其他人将永远适合不到一页。每个呈现的 ngTable 似乎都在表格下方添加了“10 25
当我单击顶部复选框时,如何选择网格上的所有复选框。此时它仅单击当前页面复选框。如果您可以在 Plunk 上模拟您的解决方案,非常感谢。提前致谢。 这是链接:Table with checkboxes
我已经使用 angularjs 和 ngTable 创建了一个具有文件管理器功能的应用程序,该应用程序在过滤方面也工作正常,但根据我的要求,过滤文本字段应该只接受 10 个字符 谁能告诉我如何将该文本
在此plunk我有一个 ngTable,其中包含动态创建的列。这些列是可排序和可过滤的,但是当单击标题时,排序不起作用,过滤器也不起作用。有什么想法吗? Javascript var app = an
我是一名优秀的程序员,十分优秀!