jQWidgets Forums

jQuery UI Widgets Forums Grid JqxCombobox remote source

This topic contains 5 replies, has 3 voices, and was last updated by  sainish 10 years, 10 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • JqxCombobox remote source #58524

    sainish
    Participant

    I am using JqxCombobox remote source. The problem i am facing is i want to already select value depending on id in combobox when i open record in editing mode

    JqxCombobox remote source #58532

    Dimitar
    Participant

    Hello sainish,

    I am not sure I understand your requirement, but if you wish to have a default selected value each time you enter edit mode, you can achieve this in the initeditor column callback function, e.g.:

    columns: [
        {
            text: 'Ship Country', datafield: 'ShipCountry', width: 150, columntype: 'combobox',
            createeditor: function (row, column, editor) {
                // assign a new data source to the dropdownlist.
                var list = ['Germany', 'Brazil', 'France'];
                editor.jqxComboBox({ autoDropDownHeight: true, source: list });
            },
            initeditor: function (row, cellvalue, editor, celltext, pressedkey) {
                editor.jqxComboBox({ selectedIndex: 2 });
            }
        },

    In the example, “France” will be selected each time but you may set the selectedIndex to a variable that changes dynamically.

    Best Regards,
    Dimitar

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

    JqxCombobox remote source #58573

    sainish
    Participant

    ` var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘prod_id’ },
    { name: ‘prod_name’ }

    ],
    url: “<?= base_url();?>helpers/productSearch”,
    data: {
    featureClass: “P”,
    style: “full”,
    maxRows: 12,
    username: “jqwidgets”
    }
    };
    var dataAdapter = new $.jqx.dataAdapter(source,
    {
    formatData: function (data) {
    if ($(“#jqxcombobox”).jqxComboBox(‘searchString’) != undefined) {
    data.name_startsWith = $(“#jqxcombobox”).jqxComboBox(‘searchString’);
    return data;
    }
    }
    }
    );
    $(“#jqxcombobox”).jqxComboBox(
    {
    width: 250,
    height: 25,
    source: dataAdapter,
    remoteAutoComplete: true,
    autoDropDownHeight: true,
    selectedIndex: 0,

    displayMember: “prod_name”,
    valueMember: “prod_id”,
    selectionMode: “dropDownList”,
    // multiSelect: true,
    renderer: function (index, label, value) {
    var item = dataAdapter.records[index];
    if (item != null) {
    var label = “(” + item.prod_name + “, ” + item.prod_id + “)”;
    return label;
    }
    return “”;
    },
    renderSelectedItem: function(index, item)
    {
    var item = dataAdapter.records[index];
    if (item != null) {
    var label = item.name;
    return label;
    }
    return “”;
    },
    search: function (searchString) {
    dataAdapter.dataBind();
    }
    });

    JqxCombobox remote source #58574

    sainish
    Participant

    how could i set default select some value if i have id or value

    JqxCombobox remote source #58575

    Peter Stoev
    Keymaster

    Hi sainish,

    I would like to answer your question instead of my colleague. You cannot select something which is not loaded. THe remote source sample of jqxComboBox demonstrate how to load items in jqxComboBox when you type something. Loading is on demand which means that the data is being loaded as you type. So, you can’t select something which is not loaded. Otherwise, if your data is not loaded on demand, you may use the Dimitar’s solution.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    JqxCombobox remote source #58592

    sainish
    Participant

    Thanks but i got the solution with this two line

    
     $("#customercombobox").jqxComboBox('insertAt',{alt_name: "<?php echo $alt_name; ?>",cust_id: "<?php echo $cust_id; ?>",name: "full name"},0);
            $("#customercombobox").jqxComboBox('selectIndex', 0 ); 
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.