1

我在 jquery 中传递了一组列,但是当我获取列的长度时,这给出了一个额外的我的代码如下

function manageUsersPage() {
this.data=null;
this.edititem=null;
this.columns = [
    [false, 'User Id', 'UserI`enter code here`d', 'readonly', 20, '', null],
    [true, 'User Name', 'fullname', 'readonly', 20, '', null],
    [true, 'Login Name', 'Login', 'string', 15, 'required', null],
    [false, 'Password', 'Password', 'password', 15, '', null],
    [false, 'Confirm Password', 'Password', 'password', 15, '', null],
    [true, 'User Type', 'UserType', 'select', 0, '', ['Hotel-Admin', 'Chain-Admin', 'User']],
    [false, 'Manage Hotels (If Chain-Admin)', 'hotels', 'multiselect', 40, '', null],
    [true, 'Email Address', 'Email', 'string', 30, 'custom[email]', null],
    [true, 'Reservation Delivery', 'ResvDelivery', 'select', 0, '', ['No Email', 'All', 'Failure', 'Failure, Pending', 'Failure, Validation', 'Failure, Validation, Rejected', 'Failure, Validation,Pnding', 'Validation,Rejected,Failure, Pnding', 'Failure, Validation,Pnding,Success']],
    [true, 'RMS Mail Delivery', 'RmsDelivery', 'select', 0, '', ['On', 'Off']],
    [false, "First Name", "FirstName", 'string', 20, '', null],
    [false, "Middle Name", "MiddleName", 'string', 20, '', null],
    [false, "Last Name", "LastName", 'string', 20, '', null],
    [false, "Address", "Address", 'text', 40, '', null],
    [false, "Comments", "Comments", 'text', 100, '', null],
    //[false, "login Status", "Loginstatus", "test", 20, '', null],
    [false, 'Mail Delivery', 'RmsDelivery', 'select', 0, '', ['No Email', 'All', 'Failure', 'Failure, Pending', 'Failure, Validation', 'Failure, Validation, Rejected', 'Failure, Validation,Pnding', 'Validation,Rejected,Failure, Pnding', 'Failure, Validation,Pnding,Success']],
];
this.edittable=null;

}

当我尝试

 var columns = this.columns, data = this.data;
          var html = '<form id=' + this.formid + '>';
          html += '<table id=' + this.tableid + ' width=100% class=tableBox>';
         html += '<thead><tr>';
        for (i = 0; i < columns.length; i++) {
        if (!columns[i][0]) continue;
        html += '<th>' + columns[i][1] + '</th>';
}

columns.length 变为 17,而 columns 为 16

4

1 回答 1

0

我认为您的代码似乎是正确的。见这里

将评论更改为:

/* [false, "login Status", "Loginstatus", "test", 20, '', null], */

根据评论

我检查了一下,似乎工作正常。

工作样本

最后我得到了错误

在数组关闭之前,您的数组最后this.columns有尾随comma(,)

删除最后一个逗号,一切都很好。

于 2012-09-11T09:15:19.113 回答