淘汰表foreach数据绑定未在表中插入任何内容

时间:2019-05-18 12:51:13

标签: javascript jquery html knockout.js datatable

我正在创建一个显示表中员工列表的网页,该列表是从Ajax调用返回到WCF服务的,返回的数据类型是带有tbl_user的列表,即实体表:返回的数据打印后具有以下表格:

UserBarcode:1 用户积分:1 UserFname:“ a” 用户名:4 用户名:“ a” 用户电话:1 UserRefillDate:“ /日期(1554827652877)/” ...

我正在尝试使用淘汰赛foreach填充表格,但没有显示任何内容

javascript:

If Number.IsMatch(InputNumberTextBox.Text) And (InputNumberTextBox.Text <> String.Empty) Then

html:

var _StartRow = 0;
var _Current_Page = 1;
var _Pages_Count = 0;
var _ChildWindow = "";
var js_Selected_News = null;
var _Person_Grid_Data = "";
var _Person_List = [];
var Params_Get_Person_By_Criteria_InList = new Object();
Params_Get_Person_By_Criteria_InList.data = ko.mapping.fromJS([]);

var _Params_Get_Person_By_Criteria_InList = ko.mapping.fromJS(Params_Get_Person_By_Criteria_InList);


$(document).ready(function () {

    var list = [
        { date: '12/1/2011', reading: 3, id: 20055 },
        { date: '13/1/2011', reading: 5, id: 20053 },
        { date: '14/1/2011', reading: 6, id: 45652 }
    ];

    console.log("ready " + list.length);
    $("title", $(window.parent.document)).html('Persons');
    SetControlsProperties();
    setActiveNavigation(2, '');
    }
);
/* --------------------------------------------------------------- */

/* SetControlsProperties */
/* --------------------------------------------------------------- */
function SetControlsProperties() {
    try {
        console.log("set control properties");
        /* ----------------- */
        ko.applyBindings(_Params_Get_Person_By_Criteria_InList, $("#news_page")[0]);
        /* ----------------- */
        Btn_Search_Click();
    }
    catch (e) {
        console.log("SetControlsProperties: " + e.message);
    }
}
/* --------------------------------------------------------------- */

/* Btn_Search_Click. */
/* --------------------------------------------------------------- */
function Btn_Search_Click() {
    try {
        console.log("btn search clicked");
        GetData();
    }
    catch (e) {
        console.log("Btn_Search_Click: " + e.message);
    }
}
/* --------------------------------------------------------------- */

/* GetData */
/* --------------------------------------------------------------- */
function GetData() {
    try {

        console.log("get data");
        _Params = ko.mapping.toJSON(_Params_Get_Person_By_Criteria_InList);
       // _Params = null;
        console.log("params: " + _Params);
        _Service_Method = "Get_Employees";
        CallService(_Service_Method, Get_Employees_Completed, Service_Call_InCompleted);

        /* ---------------- */
    }
    catch (e) {
        console.log("GetData: " + e.message);
    }
}
/* --------------------------------------------------------------- */

// Get_Person_By_Criteria_Adv
/* --------------------------------------------------------------- */
function Get_Employees_Completed(i_Input) {
    try {
        console.log("TYPE: " + typeof i_Input.EmployeesList);
        Handle_Employees_Grid(i_Input);
    }
    catch (e) {
        console.log("Get_Employees_By_Criteria_Adv_Completed: " + e.message);
    }
}
/* --------------------------------------------------------------- */

//Handle_Person_Grid
/* --------------------------------------------------------------- */
function Handle_Employees_Grid(i_Input) {
    try {
        var i_Person_List = [];
        console.log("Length: " + i_Input.EmployeesList.length);
        for (var i = 0; i < i_Input.EmployeesList.length; i++) {
            console.log(i_Input.EmployeesList[i])
            i_Person_List.push("Persons: " + i_Input.EmployeesList[i]);
        }
        console.log("persons list: " + i_Person_List.toString());
        var oTable = $('#tbl_data').dataTable();
        oTable.fnDestroy();
         $('#tbl_data tbody').html("");
        _Person_List = i_Person_List;
        _Params_Get_Person_By_Criteria_InList.data([]);
        _Params_Get_Person_By_Criteria_InList.data(i_Person_List);
        console.log("Data: "+Params_Get_Person_By_Criteria_InList.data.toString);
        Module.init();

    }
    catch (e) {
        console.log('Handle_Person_Grid :' + e.message);
    }
}
/* --------------------------------------------------------------- */

var Module = function () {
    var initTable1 = function () {

        var table = $('#tbl_data');

        table.dataTable({
            "bFilter": false,
            "bStateSave": false,
            "bLengthChange": false,
            "pageLength": _LIST_ITEMS_PER_PAGE,
            "pagingType": "bootstrap_extended",
            "language": {
                "search": "Filter",
                "paginate": {
                    "previous": "<",
                    "next": ">",
                    "page": "",
                    "pageOf": "/"
                },
                "emptyTable": "No Records",
                "infoEmpty": "No Records",
                "infoFiltered": "",
                "zeroRecords": "No Records"
            }
        });
        $(".pagination-panel-input")[0].disabled = true;
    }

    return {

        //main function to initiate the module
        init: function () {
            if (!jQuery().dataTable) {
                return;
            }
            console.log("Init table");
            initTable1();
        }

    };

} ();

0 个答案:

没有答案