jQWidgets Forums

jQuery UI Widgets Forums Lists DropDownList Get Data twice

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  simcon94 11 years, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Get Data twice #29022

    simcon94
    Participant

    Hi,
    i have a Grid. The Data for the Grid i get it from the dataAdpater.
    This dataAdapter i’d like to give to a PopUp.
    Thats not the Problem.
    The Problem is, that the PopUp has a jqxDropDownList. In these DropDownList i will give the dataAdapter as source.
    In this casse, the DropDownList will call a function in my Controller, even though I already have the data…..
    Any Idea?

    Get Data twice #29023

    simcon94
    Participant

    Thats the Code:

    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘Id’, type: ‘string’ }
    , { name: ‘Name’, type: ‘string’ }
    ],

    addrow: function (rowid, rowdata, position, commit) {
    commit(true);
    },
    updaterow: function (rowid, rowdata, commit) {
    commit(true);
    },
    deleterow: function (rowid, commit) {
    commit(true);
    $(‘#grid’).jqxGrid(‘refresh’);
    },
    // get Model Data
    url: sk.appHelper.getAppDomainAppVirtualPath() + “/Test/GetDatas”
    ,async: false
    };
    var dataAdapter = new $.jqx.dataAdapter(source);

    //call Function
    preparePopUp(dataRecord.Id, dataAdapter);

    function preparePopUp(id, dataAdapterGrid) {
    $(“#gridParentMeters”).jqxGrid(
    {
    width: popUpWidth – 10
    , autoheight: true
    , source: dataAdapter

    , selectionmode: ‘singlecell’
    , editable: true
    , columnsresize: true
    , showtoolbar: true
    , showaggregates: true
    , showstatusbar: true
    , altrows: true
    , statusbarheight: 25
    , rendertoolbar: function (toolbar) {
    var container = $(“

    “);
    var addButton = $(“

    “);
    container.append(addButton);
    toolbar.append(container);
    addButton.jqxButton({ width: 60, height: 20 });
    // add new row.
    addButton.click(function () {
    $(“#gridParentMeters”).jqxGrid(‘addrow’, ‘MeterId’, {}, ‘top’);

    });
    }
    , columns: [
    {
    text: “Id “, datafield: “Id”, width: 1, hidden: true
    , aggregatesrenderer: function (aggregates, column, element) {
    var renderstring = “

    “;
    return renderstring;
    }
    }
    , {
    text: ‘@Resources.Name’, columntype: ‘dropdownlist’, displayfield: “Name”, datafield: “Id”, width: ‘80%’,
    createeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList({ source: dataAdapterGrid, displayMember: ‘Name’, valueMember: ‘Id’, height: ’25’ });
    }

    }

    ]
    });
    }

    Get Data twice #29026

    Peter Stoev
    Keymaster

    Hi simcon94,

    It is not necessary to make another server call if you already have the data. You just have to construct a new jqxDataAdapter instance to bind a widget and the data could be local for it, if the data is already downloaded.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Get Data twice #29027

    simcon94
    Participant

    Do you have an example?

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

You must be logged in to reply to this topic.