This is a migrated thread and some comments may be shown as answers.

Grid Filter

2 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Su
Top achievements
Rank 1
Su asked on 12 May 2014, 02:03 AM
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('');
    },

2 Answers, 1 is accepted

Sort by
0
Su
Top achievements
Rank 1
answered on 12 May 2014, 04:06 AM
Seems both my screenshots did not get posted. Therefore attaching them.
0
Rosen
Telerik team
answered on 13 May 2014, 12:25 PM
Hello Su,

I'm afraid that filtering/sorting/grouping on array as column value is not supported. Thus, you will need to modify the data and project the value as top level properties. This can be achieved on the fly via DataSource's schema parse function. Here you can find a simple test page which demonstrate basic implementation of this approach.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Su
Top achievements
Rank 1
Answers by
Su
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or