数据表未在angularjs中重新加载

数据表未在angularjs中重新加载

本文介绍了数据表未在angularjs中重新加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求,我必须将特定产品添加到数据表并重新绑定该数据表,以便更新其计数.我正在使用MVC和angularjs 1.6.2

I have a requirement where i have to add particular products to the datatables and rebind the datatable so its count is updated. I am using MVC and angularjs 1.6.2

我正在如下创建数据表:

I am creating the datatable as follows:

<table id="dtProducts" ng-if="AllProducts"
       class="table manage-user-table offer-mgt-table market-selection-tab"
       datatable="ng" dt-options="dataTableOpt">
    <thead>
        <tr>
            <th><input type='checkbox' class="selectAllMarket"
                       value='SelectAll' ng-model="selectAll" >
            </th>
            <th>Product Name</th>
            <th>Product Type</th>
        </tr>
    </thead>
    <tbody>
        <tr dt-rows ng-repeat="product in AllProducts">
            <td><input type="checkbox" class="selectMarket"
                       ng-model="product.selected"
                       data-offerid="{{product.ID}}"
                       ng-click="toggleSelect(product.selected, $index)">
            </td>
            <td>{{product.Name}}</td>
            <td>{{product.VerticalType.VerticalTypeDisplayName}}</td>

        </tr>
    </tbody>
</table>

视图上有一个部分,其中包含一个用于获取产品名称的文本框和一个用于获取产品类型的下拉菜单,还包含一个按钮,该按钮单击服务器上的帖子被点击时为了保存该产品,并确保该帖子在前端成功运行,我调用函数以重新加载AllProducts.调用该函数后,我立即收到错误消息

There a section on a view that contains a text box to take product name and a dropdown to take product type.It also contains an button on clicking the button a post is hit on the server to save that product and on the success of that post on front end i call function to reload the AllProducts. As soon as that function is called i get the error

将产品保存到表中之后,通过以下代码完成数据表的重新加载

Reloading of the datatable is done through the following code after saving of products in the table

var getAllProducts = function () {
    var urlgetAllProducts = apiURL + "/AllProducts?providerId=" + providerID;
    $http({
        url: urlgetAllProducts,
        method: 'GET', //$scope.customization,
    }).then(function successcallback(response) {

        $scope.AllProducts = response.data.ResponseData;


        $scope.$parent.AllProducts = $scope.AllProducts;
        if ($scope.offer.ProductList != undefined) {

            MakeSelected();
            $scope.selectProducts();

        }

    },
    function errorcallback(response) {
    }).then(function () {
    });
}

有人可以在这方面帮助我吗?我正在使用angulardatatables 0.6.2.如果需要,我可以提供更多详细信息.谢谢

Can anyone help me in this regard? I am using angulardatatables 0.6.2. I can provider more details if needed. Thanks

推荐答案

我找到了解决方案.由于它引起问题,我懒洋洋地束缚着图书馆.通过将加载部分放入setTimeout中,它就像一个魅力

I found solution to it. I was lazily binding the library due to which it was causing issues. By putting the loading part in the setTimeout it worked like a charm

这篇关于数据表未在angularjs中重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 02:03