So i run my web-aaplication and get this error Length of colNames <> colModel! The problem is that the number of colName & colModel is the same, so I really dont know what
s the point.
usersandorganization.js
var initActiveUsers = function(){
if (!activeUsersGrid) {
activeUsersGrid = $('#activeUsers').jqGrid({
datatype: function(){
commonHelper.callAjaxMethod('users.htm', 'loadActiveUsers',
{}, function (result) {
activeUsersGrid.clearGridData(true);
activeUsersGrid[0].addJSONData(result);
}, true, true, false, function(){return true;})
},
colNames: [
messages['usersandorganizations.loginname'],
messages['usersandorganizations.name'],
messages['usersandorganizations.logindate'],
messages['usersandorganizations.session'],
messages['usersandorganizations.description']
],
colModel: [
{name: 'loginName', index: 'loginName', formatter: commonHelper.notNullFormatter},
{name: 'name', index: 'name', formatter: commonHelper.notNullFormatter},
{name: 'loginDate', index: 'loginDate', formatter: commonHelper.notNullFormatter},
{name: 'sessionId', index: 'sessionId', formatter: commonHelper.notNullFormatter},
{name: 'description', index: 'description', formatter: commonHelper.notNullFormatter},
],
height: "100%",
jsonReader: {repeatitems: false, id: "loginName"},
sortname: 'loginDate',
viewrecords: true,
sortorder: "asc",
rowNum: -1
});
updateActiveUsers();
} else {
activeUsersGrid.trigger("reloadGrid");
}
};
I'm not sure if this causes the problem, but you have not needed comma after the last element in colModel
{name: 'description', index: 'description', formatter: commonHelper.notNullFormatter}, <==
Are you sure that messages array has values which are not separated with commas - this may cause the problem
You can create a temporary element before calling the grid and do
var names_check = [
messages['usersandorganizations.loginname'],
messages['usersandorganizations.name'],
messages['usersandorganizations.logindate'],
messages['usersandorganizations.session'],
messages['usersandorganizations.description']
]
console.log(names_check.length);
You will see the dimension of the names array.
If you do not want to perform this you can simple replace the colNames array and use the label property in colModel - i.e Remove the colNames and do:
colModel: [
{label: messages['usersandorganizations.loginname'], name: 'loginName', index: 'loginName', formatter: commonHelper.notNullFormatter},
...
],
Hope you have got the point.
I think if there is a problem with the messages array (as mentioted above) you will have a error too when using the last recommendation.