我想弄清楚如何填充一個ng表,並應用params的總值。它似乎有被顯示幾乎我在做什麼的例子 - 但不完全和totla永遠不會設置 -從分頁服務器角度ng表加載
$scope.tableParams = new NgTableParams({page: 1, count: 25},
{
counts: [],
getData: function(params)
if (CompaniesView.ViewInitialized)
return CompaniesView.RetrieveCompanies($scope, $http, function()
{
params.total($scope.RequestFilter.TotalCompanies);
return $scope.TableParams.data;
});
}
});
我RetrieveCompanies函數檢索他的數據 - 並調用回調函數完成。我在這個印象之下我可以設置params.total,但沒有工作。我發現這些例子都是類似的,只是它們直接執行jquery API操作。我不知道爲什麼這不起作用。我會認爲隨時設置總數會導致表分頁控件更新 - 但它似乎必須在detData調用內完成。但是,如果您正在進行異步調用,我們如何才能在調用中設置總數,因爲直到異步完成時纔會有數據 - 這意味着getData調用已完成。
可能在這裏丟失了一些概念 - 但我不是jquery或angular的專家。
彼得
更新: RetieveCompanies功能
RetrieveCompanies: function (scope, http,callback)
{
scope.IsLoading = true;
var Data =
{
AuthoirzationType: TokenRetrieval.SessionAuth,
SessionId: activeSession
};
var tokenRequest =
{
params: Data
};
performVeilabilityTokenRetrieval(http, tokenRequest,
function (response)
{
if (true)
{
if (!response.HasError)
{
scope.RequestFilter.State = scope.selectedState.Value
scope.RequestFilter.regionsearch = scope.selectedRegion.id;
scope.RequestFilter.checkadminStaff = scope.selectedAdmin.value;
//tableParams
scope.RequestFilter.Page = scope.tableParams.page();
scope.RequestFilter.PageCount = scope.tableParams.count();
var config =
{
headers:
{
Authorization: 'Bearer ' + response.RequestToken
},
params: scope.RequestFilter
}
http.get(CompaniesView.Companies_api_urls.loadCompaniesRequest, config)
.then(
function (response)
{
scope.RequestFilter.TotalCompanies = response.data.companieslistTotal;
scope.TableParams.data = response.data.companies;
if (callback != null) callback();
},
function (data, status, headers, config) //error
{
scope.IsLoading = false;
}
);
}
else
{
scope.request.requestToken = null;
//CreateExpenseView.PrepareRESTResults(data.RestResults);
}
}
else
{
scope.request.requestToken = null;
scope.request.error = data.replace(/\"/g, "");
}
});
}
您能否顯示RetrieveCompanies功能? – digit