Hello,
I am trying to make this grid using Json. The filters for Country code and Company codes are not working. I have attached the screenshot of the grid (grid value is not provided for security of data). As you can understand form the code snippet that "userConstraints" field is an object which later split into two columns Country Code and Company Code and where the filters are not working. I would like to make it work in client side. Do not prefer to solve it in sever side. Please let me know if i missed anything. Thanks in advance!
Screen Shot:
![]()
Json Data for Field "userConstraints"
![]()
Code Snippet:
getUsers: function (data, response) {
permissionManagementViewModel.SubjectRoleMapping(response);
$('#RolesGrid').html();
$('#RolesGrid').kendoGrid({
dataSource: {
data: response,
batch: false,
pageSize: 10,
schema: {
model: {
fields: {
AccountName: { editable: false },
RoleName: { editable: false },
ConstraintsExpression: { editable: false },
userConstraints: { editable: false },
Status: { editable: false }
}
}, parse: function (data) {
$.each(data, function (i, val) {
});
return data;
}
}
},
editable: true,
filterable: {
extra: true, //do not show extra filters
operators: { // redefine the string operators
string: {
contains: "Contains",
startswith: "Starts With",
eq: "Is Equal To",
doesnotcontain: "Does not contain",
endswith: "Ends with",
neq: "Is not equal to"
}
}
},
pageable: true,
scrollable: true,
resizable: true,
sortable: true,
selectable: true,
resizable: true,
columns: [
{ field: "AccountName", title: "User Name", width: '150px' },
{ field: "RoleName", title: "Role Name", width: '150px' },
{ field: "Status", hidden: true },
{ field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode') #</span>", title: "Country Codes", width: '100px' },
{ field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode') #</span>", title: "Company Codes", width: '100px' },
{ field: "", title: "View/Edit", width: '80px', template: "<input class='btnViewPermissions' type='button' value='View/Edit' onclick='javascript:permissionManagementViewModel.ViewUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\", \"#=Status#\")' />" },
{ field: "", title: "Delete", width: '80px', template: "<input class='btnDeletePermissions' type='button' value='Delete' onclick='javascript:permissionManagementViewModel.DeleteUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\")' />" }
]
})
var grid = $("#RolesGrid").data("kendoGrid");
grid.bind("dataBound", onpermissionsDataBound);
grid.dataSource.fetch();
permissionManagementViewModel.Action('');
},
I am trying to make this grid using Json. The filters for Country code and Company codes are not working. I have attached the screenshot of the grid (grid value is not provided for security of data). As you can understand form the code snippet that "userConstraints" field is an object which later split into two columns Country Code and Company Code and where the filters are not working. I would like to make it work in client side. Do not prefer to solve it in sever side. Please let me know if i missed anything. Thanks in advance!
Screen Shot:
Json Data for Field "userConstraints"
Code Snippet:
getUsers: function (data, response) {
permissionManagementViewModel.SubjectRoleMapping(response);
$('#RolesGrid').html();
$('#RolesGrid').kendoGrid({
dataSource: {
data: response,
batch: false,
pageSize: 10,
schema: {
model: {
fields: {
AccountName: { editable: false },
RoleName: { editable: false },
ConstraintsExpression: { editable: false },
userConstraints: { editable: false },
Status: { editable: false }
}
}, parse: function (data) {
$.each(data, function (i, val) {
});
return data;
}
}
},
editable: true,
filterable: {
extra: true, //do not show extra filters
operators: { // redefine the string operators
string: {
contains: "Contains",
startswith: "Starts With",
eq: "Is Equal To",
doesnotcontain: "Does not contain",
endswith: "Ends with",
neq: "Is not equal to"
}
}
},
pageable: true,
scrollable: true,
resizable: true,
sortable: true,
selectable: true,
resizable: true,
columns: [
{ field: "AccountName", title: "User Name", width: '150px' },
{ field: "RoleName", title: "Role Name", width: '150px' },
{ field: "Status", hidden: true },
{ field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode') #</span>", title: "Country Codes", width: '100px' },
{ field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode') #</span>", title: "Company Codes", width: '100px' },
{ field: "", title: "View/Edit", width: '80px', template: "<input class='btnViewPermissions' type='button' value='View/Edit' onclick='javascript:permissionManagementViewModel.ViewUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\", \"#=Status#\")' />" },
{ field: "", title: "Delete", width: '80px', template: "<input class='btnDeletePermissions' type='button' value='Delete' onclick='javascript:permissionManagementViewModel.DeleteUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\")' />" }
]
})
var grid = $("#RolesGrid").data("kendoGrid");
grid.bind("dataBound", onpermissionsDataBound);
grid.dataSource.fetch();
permissionManagementViewModel.Action('');
},