jQuery UI Widgets Forums Grid Updating a jqxgrid Dropdownlist column by php

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 7 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • magostoni
    Participant

    Hello,
    here the situation:

    I have a jqxgrid, with some columns, and I updated the values by php on server side, using AJAX.

                    updaterow: function (rowid, rowdata, commit){
                        var data = "update=true&" + $.param(rowdata);
    
                        $.ajax({
                            dataType: 'json',
                            url: '<?php echo site_url('/Gestprev_listini/update_listino');?>',
                            cache: false,
                            data: data,
                            success: function (data, status, xhr)
                            {
                                // success notification
                                commit(true);
                            },
                            error: function(jqXHR, textStatus, errorThrown)
                            {
                                // error notification
                                commit(false);
                            }
                        });
                    },
    

    One of them use a jqxDropDownlist editor;

                var TipoSource = [
                    { value: "V", label: "Vendita"},
                    { value: "A", label: "Acquisto"}
                ];
                var TipoDataAdapter = new $.jqx.dataAdapter(TipoSource, {
                    autoBind: true, autoSort: true, autoSortField: 'label'
                });

    ….
    ….

                            { text: 'Tipo', editable:true, dataField: 'AV', width: '10%', cellsalign: 'center', filtertype: 'checkedlist', columntype: 'dropdownlist', cellsrenderer: cellsrenderer, filteritems: TipoDataAdapter,
                                createEverPresentRowWidget: function (datafield, htmlElement, popup, addCallback) {
                                    var inputTag = $("<div style='border: none;'></div>").appendTo(htmlElement);
                                    inputTag.jqxDropDownList({ popupZIndex: 99999999, placeHolder: "Digita Tipo: ", source: TipoDataAdapter, displayMember: 'label', valueMember: 'value', width: '100%', height: 30 });
                                    $(document).on('keydown.productname', function (event) {
                                        if (event.keyCode == 13) {
                                            if (event.target === inputTag[0]) {
                                                addCallback();
                                            }
                                            else if ($(event.target).ischildof(inputTag)) {
                                                addCallback();
                                            }
                                        }
                                    });
                                    return inputTag;
                                },
                                getEverPresentRowWidgetValue: function (datafield, htmlElement, validate) {
                                    var selectedItem = htmlElement.jqxDropDownList('getSelectedItem');
                                    if (!selectedItem)
                                        return "";
                                    var value = selectedItem.value;
                                    return value;
                                },
                                resetEverPresentRowWidgetValue: function (datafield, htmlElement) {
                                    htmlElement.jqxDropDownList('clearSelection');
                                },
                                createeditor: function (row, value, editor) {
                                    editor.jqxDropDownList({ source: TipoDataAdapter, displayMember: 'label', valueMember: 'value' });
                                },
                                cellvaluechanging: function (row, column, columntype, oldvalue, newvalue)
                                {
                                    if (newvalue == "") return oldvalue;
                                },
                                cellendedit: function (row, datafield, columntype, newValue, editorvalue) {
                                    console.log(newValue);
                                    return newValue;
                                }
                            },

    Unfortunatly, for the “Tipo” field, it is passing to “updaterow” method the label content (for example ‘Acquisto’ and not ‘A’) so the php update fails.
    Is the any way to get the value of the dropdownlist widget in the updaterow method?

    Kind regards,
    Matt


    Hristo
    Participant

    Hello Matt,

    You could use an additional variable that will contain the ‘value’ of the DropDownList.
    You should to implement “geteditorvalue”, too:

    var newSetValue = null;
    ...
    geteditorvalue: function (row, cellvalue, editor) {
    // return the editor's value.
    var item = editor.jqxDropDownList('getSelectedItem');
    
    if (item != undefined) {
      newSetValue = item.value;
      return item.label;
    }

    Hope this helps.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.