jQWidgets Forums

jQuery UI Widgets Forums Grid Grid custom filter Key-value problem

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 8 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Grid custom filter Key-value problem #87116

    westbb
    Participant

    Hi, I am using asp net mvc and have this kind of problem. I have grid and this grid contains list of enum dropdownlist(Gender: Male=1, Female=2); I am filtering server side but with this column something is wrong;

    var gendersource =
                {
                    datatype: "json",
                    datafields: [
                        { name: 'ID', type: 'number' },
                        { name: 'Name', type: 'string' }
                    ],
                    async: false,
                    id: 'ID',
                    url: '/Employees/GetGenders'
                };
    
    var genderdataAdapter = new $.jqx.dataAdapter(gendersource);
    
    var source = {
                    datatype: "json",
                    datafields: [
                        { name: 'ID' },
                        { name: 'Firstname' },
                        { name: 'Lastname' },
                        { name: 'PersonalNO' },
                        { name: 'GenderName', type: 'string', value: 'Gender', values: { source: genderdataAdapter.records, value: 'ID', name: 'Name' } },
                        { name: 'BirthDate', type: 'date' },
                        { name: 'Gender', type: 'number' },
    
                    ],
                    sort: function () {
                        $("#jqxgrid").jqxGrid('updatebounddata', 'sort');
                    },
                    root: 'Rows',
                    filter: function () {
                        $("#jqxgrid").jqxGrid('updatebounddata', 'filter');
                    },
                    beforeprocessing: function (data) {
                        source.totalrecords = data.TotalRows;
                    },
                    sortcolumn: 'Firstname',
                    sortdirection: 'asc',
                    formatdata: function (data) {
                        data.pagenum = data.pagenum || 0;
                        data.pagesize = data.pagesize || 10;
                        data.sortdatafield = data.sortdatafield || 'Firstname';
                        data.sortorder = data.sortorder || 'asc';
                        data.filterscount = data.filterscount || 0;
                        formatedData = buildQueryString(data);
                        return formatedData;
                    },
                    url: '/Employees/list'
                };
    
    var dataAdapter = new $.jqx.dataAdapter(source, {
                    contentType: 'application/json; charset=utf-8',
                    loadError: function (xhr, status, error) {
                        alert(error);
                    }
                });
    
     $("#jqxgrid").jqxGrid({
                    width: '100%',
                    source: dataAdapter, 
                    pageable: true,
                    autoheight: true,
                    showfilterrow: true,
                    filterable: true,
                    sortable: true,
                    columns: [
                        { text: 'First name', dataField: 'Firstname', filtercondition: 'contains', width: '20%' },
                        { text: 'Last name', dataField: 'Lastname', filtercondition: 'contains', width: '20%' },
                        { text: 'Personal NO', dataField: 'PersonalNO', filtercondition: 'contains', width: '20%' },                    
                        {
                            text: 'Gender', filtertype: 'list', width: '20%', filteritems: new $.jqx.dataAdapter(gendersource), dataField: 'Gender', displayfield: 'GenderName',
                            createfilterwidget: function (column, htmlElement, editor) {
                                editor.jqxDropDownList({ displayMember: "Name", valueMember: "ID" });
                            }
                        },
                        { text: 'Birth Date', dataField: 'BirthDate', cellsformat: 'yyyy-MM-dd', filtertype: 'range', width: '20%' }
                    ]
                });

    in server side somehow filterValue0 is Male or Female Depending which one you choose and filterDataField0 is ‘GenderName’, but this is not correct I want to do tahe filterValue0 = 1 or 2 and filterDataField0 = ‘Gender’.

    Grid custom filter Key-value problem #87148

    westbb
    Participant

    Dose anybody has problem like this?

    Grid custom filter Key-value problem #87232

    Hristo
    Participant

    Hello westbb,

    Could you tell are there some errors messages in the console?
    Also please check the received values are correct?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.