jQWidgets Forums

jQuery UI Widgets Forums Grid Binding not working

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Binding not working #61050

    xaviergxf
    Participant

    Hi,

    I don’t know why the dropdownlist fields are not binding. Is there a event with binding errors? Anyone has a clue why its not working?

    $(document).ready(function () {
    var StartupTypeRequest = new $.jqx.dataAdapter({datatype: ‘json’, mapChar: ‘.’, async: false, id:’value’, datafields:[{name: ‘value’, type:’number’}, {name: ‘label’, type: ‘string’}], localdata: [{“value”:3,”label”:”RESTART”},{“value”:2,”label”:”STOP”},{“value”:0,”label”:”NONE”},{“value”:1,”label”:”START”}]},
    {
    autoBind: true
    });
    var StartupType = new $.jqx.dataAdapter({datatype: ‘json’, mapChar: ‘.’, async: false, id:’value’, datafields:[{name: ‘value’, type:’number’}, {name: ‘label’, type: ‘string’}], localdata: [{“value”:0,”label”:”MANUAL”},{“value”:1,”label”:”AUTOMATIC”}]},
    {
    autoBind: true
    });

    var source = {
    type: ‘POST’,
    datatype: ‘json’,
    mapChar: ‘.’,
    datafields: [{name: ‘ID’, map:’ID’,type:’string’},{name: ‘MaxSuccessfullyExecutions’, map:’MaxSuccessfullyExecutions’,type:’number’},{name: ‘HostName’, map:’HostName’,type:’string’},{name:’StartupType!disp’, value: ‘StartupType’, values: { source: StartupType.records, value:’value’, name:’label’}},{name: ‘StartupType’, map:’StartupType’,type:’number’},{name:’StartupTypeRequest!disp’, value: ‘StartupTypeRequest’, values: { source: StartupTypeRequest.records, value:’value’, name:’label’}},{name: ‘StartupTypeRequest’, map:’StartupTypeRequest’,type:’number’},{name: ‘ProcessScheduleID’, map:’ProcessScheduleID’,type:’string’},{name: ‘Retries’, map:’Retries’,type:’number’},{name: ‘Name’, map:’Name’,type:’string’},{name: ‘Description’, map:’Description’,type:’string’},{name: ‘Enabled’, map:’Enabled’,type:’bool’},{name: ‘Audit’, map:’Audit’,type:’bool’},{name: ‘AssemblyID’, map:’AssemblyID’,type:’string’},{name: ‘AssemblyQualifiedName’, map:’AssemblyQualifiedName’,type:’string’},{name: ‘Args’, map:’Args’,type:’string’},{name: ‘CreateDate’, map:’CreateDate’,type:’date’},{name: ‘LastModifiedDate’, map:’LastModifiedDate’,type:’date’}],
    url: window.location+’/GetAll’,
    // update the grid and send a request to the server.
    filter: function () {
    $(‘#56dfb2c6-a237-42f9-93ac-9f78d09e8bb5’).jqxGrid(‘updatebounddata’, ‘filter’);
    },
    // update the grid and send a request to the server.
    sort: function () {
    $(‘#56dfb2c6-a237-42f9-93ac-9f78d09e8bb5’).jqxGrid(‘updatebounddata’, ‘sort’);
    }
    };
    var dataadapter = new $.jqx.dataAdapter(source, {
    autoBind: true,
    mapChar: ‘.’,
    loadError: function (xhr, status, error) {
    alert(error);
    },
    formatData: function (data) {
    $.extend(data, {
    fmw_avm: ‘f59ee90c-3ba0-4b73-baed-3273bf0147e9’,
    fmw_av: ApplicationViewContext.ApplicationViewID
    });
    return data;
    },
    loadServerData: function (serverdata, source, callback) {
    $.ajax({
    dataType: source.datatype,
    url: source.url,
    data: serverdata,
    success: function (data, status, xhr) {
    callback({ records: $(data.Members[0]), totalrecords:data.Members[0].length });
    }
    });
    }
    });
    // initialize jqxGrid
    $(‘#56dfb2c6-a237-42f9-93ac-9f78d09e8bb5′).jqxGrid({
    source: dataadapter,
    width:’100%’,
    autoheight: true,
    editable: true,
    filterable: true,
    autoshowfiltericon: true,
    updatefilterconditions: function (type, defaultconditions) {
    var stringcomparisonoperators = [‘EMPTY’, ‘NOT_EMPTY’, ‘CONTAINS’,
    ‘DOES_NOT_CONTAIN’, ‘STARTS_WITH’,
    ‘ENDS_WITH’, ‘EQUAL’, ‘NULL’, ‘NOT_NULL’];
    var numericcomparisonoperators = [‘EQUAL’, ‘NOT_EQUAL’, ‘LESS_THAN’, ‘LESS_THAN_OR_EQUAL’, ‘GREATER_THAN’, ‘GREATER_THAN_OR_EQUAL’, ‘NULL’, ‘NOT_NULL’];
    var datecomparisonoperators = [‘EQUAL’, ‘NOT_EQUAL’, ‘LESS_THAN’, ‘LESS_THAN_OR_EQUAL’, ‘GREATER_THAN’, ‘GREATER_THAN_OR_EQUAL’, ‘NULL’, ‘NOT_NULL’];
    var booleancomparisonoperators = [‘EQUAL’, ‘NOT_EQUAL’];
    switch (type) {
    case ‘stringfilter’:
    return stringcomparisonoperators;
    case ‘numericfilter’:
    return numericcomparisonoperators;
    case ‘datefilter’:
    return datecomparisonoperators;
    case ‘booleanfilter’:
    return booleancomparisonoperators;
    }
    },
    sortable: true,
    groupable: true,
    pageable: true,
    virtualmode: true,
    columnsresize: true,
    columns: [{text: ‘ID’, pinned:true, editable: false, datafield:’ID’ },{text: ‘MaxSuccessfullyExecutions’, datafield:’MaxSuccessfullyExecutions’ },{text: ‘HostName’, datafield:’HostName’ },{text: ‘StartupType’, displayfield:’StartupType!disp’, columntype: ‘dropdownlist’, initeditor: function (row, value, editor) {
    editor.jqxDropDownList({ source: StartupType, displayMember: ‘label’, valueMember: ‘value’ });
    }, datafield:’StartupType’ },{text: ‘StartupTypeRequest’, displayfield:’StartupTypeRequest!disp’, columntype: ‘dropdownlist’, initeditor: function (row, value, editor) {
    editor.jqxDropDownList({ source: StartupTypeRequest, displayMember: ‘label’, valueMember: ‘value’ });
    }, datafield:’StartupTypeRequest’ },{text: ‘ProcessScheduleID’, datafield:’ProcessScheduleID’ },{text: ‘Retries’, datafield:’Retries’ },{text: ‘Name’, datafield:’Name’ },{text: ‘Description’, datafield:’Description’ },{text: ‘Enabled’,columntype:’checkbox’, datafield:’Enabled’ },{text: ‘Audit’,columntype:’checkbox’, datafield:’Audit’ },{text: ‘AssemblyID’, datafield:’AssemblyID’ },{text: ‘AssemblyQualifiedName’, datafield:’AssemblyQualifiedName’ },{text: ‘Args’, datafield:’Args’ },{text: ‘CreateDate’, editable: false,columntype:’datetimeinput’, filtertype: ‘range’, cellsformat: ‘M/d/yyyy h:mm:ss tt’ , datafield:’CreateDate’ },{text: ‘LastModifiedDate’, editable: false,columntype:’datetimeinput’, filtertype: ‘range’, cellsformat: ‘M/d/yyyy h:mm:ss tt’ , datafield:’LastModifiedDate’ }],
    rendergridrows: function (obj) {
    return obj.data;
    }
    });
    $(‘#56dfb2c6-a237-42f9-93ac-9f78d09e8bb5’).bind(‘bindingcomplete’, function (event) {
    $(‘#56dfb2c6-a237-42f9-93ac-9f78d09e8bb5’).jqxGrid(‘autoresizecolumns’);
    });
    });

    Thank you

    Binding not working #61055

    Peter Stoev
    Keymaster

    Hi xaviergxf,

    If you have some data binding errors, check your browser’s debugger console or network windows. You can also add the loadError callback function of jqxDataAdapter which provides helpful information and may help you to understand what you’re doing wrong. You can learn about it here: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxdataadapter/jquery-data-adapter.htm

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Binding not working #61081

    xaviergxf
    Participant

    Hi Peter,

    I have a json structure like:
    {
    “Members”: {
    “0”: [
    {
    “MaxSuccessfullyExecutions”: -1,
    “HostName”: “*”,
    “StartupType”: 1,
    “StartupTypeRequest”: 0,

    },
    {
    “MaxSuccessfullyExecutions”: -1,
    “HostName”: “*”,
    “StartupType”: 1,
    “StartupTypeRequest”: 0,

    }
    }
    }

    Is there a way of setting the records as: Members[“0”] instead of implementing the loadServerData at the dataAdapter, and loosing its base functionality? My current problem is: one of the columns of the grid has a dropdownlist which has no values selected, and i believe that the problem is at the implementation of loadServerData which doesn’t set the correct value to the dropdownlist.

    Thank you

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

You must be logged in to reply to this topic.