jQWidgets Forums

jQuery UI Widgets Forums Grid Jqxgrid width column jqxdropdownlist

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

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • Jqxgrid width column jqxdropdownlist #86681

    GabrielCostaAlves
    Participant

    Hi, I´m using jqxdropdownlist inside jqxgrid. In function initeditor I need get ‘value’ dropdownlist and no ‘label’, cellvalue is always label, I need ‘value’.

    My dropdown code:

    var locallista = [{ value: “5289”, label: “Americanas”},
    { value: “5290”, label: “Loja 01”}
    ];

    var locallistaSource = {
    datatype: “array”,
    datafields: [ { name: ‘label’, type: ‘string’ }, { name: ‘value’, type: ‘string’ } ],
    localdata: locallista
    };

    var locallistaAdapter = new $.jqx.dataAdapter(locallistaSource, {
    autoBind: true
    });

    {columns: [

    { text: “Local Lista”, width: “100”, dataField: “7115”, columntype: ‘custom’,
    createeditor: function (row, column, editor) {
    editor.jqxDropDownList({source: locallistaAdapter, displayMember: ‘label’, valueMember: ‘value’, filterable: false,
    placeHolder: ‘Choose…’});},
    initeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList(‘selectItem’, cellvalue);
    }},
    }

    In my list I have value: “5289”, label: “Americanas”, I want get value : “5289” in initeditor

    Best Regards

    Jqxgrid width column jqxdropdownlist #86698

    Hristo
    Participant
    Jqxgrid width column jqxdropdownlist #86711

    GabrielCostaAlves
    Participant

    Hi, Thanks for the answer.

    But I need get de value using initeditor.

    I want use:

    initeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList(‘selectItem’, cellvalue);
    }}.

    But cellvalue is label, then I need value dropdown.

    Or, Is there another way to set the selected value during initeditor?

    Tks

    Best Regards

    Jqxgrid width column jqxdropdownlist #86736

    Hristo
    Participant

    Hello GabrielCostaAlves,

    You could try to use setContent.
    About this ( editor.jqxDropDownList(‘selectItem’, cellvalue); ) row in your code is no matter to use because in that moment when try to select item is the exactly same.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Jqxgrid width column jqxdropdownlist #86754

    GabrielCostaAlves
    Participant

    Hi,

    But if I use setContent, I´m setting new content. I don´t want this. I want set some value of my list as content.

    var locallista = [{ value: “5289”, label: “Americanas”},
    { value: “5290”, label: “Loja 01”}
    ];

    Example:

    initeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList(‘setContent’, cellvalue);
    }}.

    If I use this, I´m setting the label, but I want set the value of my list.

    I Try this, It´s work.

    initeditor: function (row, cellvalue, editor) {
    editor.jqxDropDownList(‘setContent’, 5289);
    }}.

    But, I want this dynamically. For Example:

    editor.jqxDropDownList(‘setContent’, value);

    Best Regards

    Jqxgrid width column jqxdropdownlist #86768

    Hristo
    Participant

    Hello GabrielCostaAlves,

    Please, take a look this example:
    https://www.jseditor.io/?key=grid-with-dropdownlist
    Could you tell what you want to achieve and what is not right if we based on the example above?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Jqxgrid width column jqxdropdownlist #86779

    GabrielCostaAlves
    Participant

    Hi,

    I want achieve the value jqxdropdown, not label.

    In your example, You are using $(“#jqxgrid”).on(‘cellvaluechanged’, function (event), I want uset initeditor.

    I found a workaround , but it’s not the ideal, because if I have equals labels, I don´t know what value.

    My solution:

    initeditor: function (row, cellvalue, editor) {
    var items = editor.jqxDropDownList(‘getItems’);
    var value = getListValue(items, cellvalue);
    editor.jqxDropDownList(‘selectItem’, value);
    }

    function getListValue(items, value) {
    for (var i = 0; i < items.length; i++) {
    if (value == items[i].label) {
    return items[i].value;
    }
    }
    }

    Based in my solution, Do you have other suggestions?

    Best Regards.

    Jqxgrid width column jqxdropdownlist #86805

    Hristo
    Participant

    Hello GabrielCostaAlves,

    I guess it’s a little confusing with this example.
    In my example has two columns in the Grid. First column ‘Value’ represent the id of the item (it is equal to your data ‘values’).
    Second column ‘Local Lista’ represent the name of the item (it is equal ‘label’ from data (locallista)).
    This is not editable column, it is used only to shows the name of the chosen element.
    In the first column I was thinking you want to show some title of the element (in my case combination from “id” + “name” it is equal to [label + ‘ – ‘ + value]).
    If you would like to change simply change returned string in renderer of the jqxDropDownList.
    I asked you ‘what you want to achieve’ because I would like to create the example together with you and with the behavior that you want.
    Please, take a look this example.
    I have one suggestion about your getListValue function could search by ID and return the desired value.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Jqxgrid width column jqxdropdownlist #86809

    GabrielCostaAlves
    Participant

    Hi,

    I forgot, but I´m using editable column.

    I need after click in edit button get value in my data and use in editor.jqxDropDownList(‘selectItem’, value); inside initeditor

    Jqxgrid width column jqxdropdownlist #86820

    GabrielCostaAlves
    Participant

    Hi,

    Your example work now. But I have one problem.

    The same problem my function getListValue, the problem is when have two name (label) equals.

    Insert in your example the follow data and you see the problem:

    This because the displayMember needs name, not id.

    var locallista = [
    { id: “5289”, name: “Americanas” },
    { id: “5290”, name: “Loja 01” },
    { id: “5302”, name: “Loja 01” }
    ];

    In this case the value is always 5290, because is the first.

    After this I need getValue, for example, I select “Americanas”, then I want “5289”

    Best Regards.

    Jqxgrid width column jqxdropdownlist #87001

    Hristo
    Participant

    Hello GabrielCostaAlves,

    Please, take a look this example:
    https://www.jseditor.io/?key=grid-with-dropdownlist-edited2
    You could get ‘id’ with bind to ‘cellvaluechanged’ because in this scenario ‘geteditorvalue’ callback will return the name of this item.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.