Author Topic: setting/changing cell data in a row with editors and formatting  (Read 8199 times)

urnerbarry

  • Newbie
  • *
  • Posts: 2
    • View Profile
Hello,

I am new to using ParamQuery Pro. I'm having trouble setting/changing the contents of row data dynamically. My grid has 7 Columns:
ItemName (DropDownList editor),
LineDesc,
ClassName (DropDownList editor),
UnitPrice (datatype:float),
Quantity (datatype:integer),
ExtendedAmount (datatype:float, editable=false) -- this is a computed column based on UnitPrice & Quantity,
Tax (DropDownList editor)

When an Item is selected in ItemName, I want to populate the remaining columns from my JSON data. I am using the cellSave event as follows:

cellSave: function (evt, ui) {
                        var dataIndx = ui.dataIndx;
                        var rowIndx = ui.rowIndx;

                        if (dataIndx == 'ItemName') {
                            var id = $('.itemsListData').val();

                            $.each(itemsJson, function (i, val) {
                                if (val.ItemLookupId == id) {
                                    ui.rowData['LineDesc'] = val.LineDesc;
                                    ui.rowData['ClassName'] = val.ClassName;
                                    ui.rowData['UnitPrice'] = val.UnitPrice;
                                    ui.rowData['Quantity'] = val.Quantity;
                                    ui.rowData['ExtendedAmount'] = val.ExtendedAmount (is present in JSON when no UnitPrice given);
                                    ui.rowData['TaxDesc'] = val.TaxDesc;
                                }

                            });
                        }


                        if (dataIndx == 'Quantity' || dataIndx == 'UnitPrice') {
                            $grid.pqGrid('refreshCell', { dataIndx: 'ExtendedAmount', rowIndx: rowIndx });
                        }
                    }

The LineDesc column works and displays properly, but none of the other columns are displaying. I'm not sure if I am setting the other drop down list editors properly. I also noticed that if I tab to the numeric datatype columns that the value is there in edit mode but does not display on screen. Can you please advise?

Thank you!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: setting/changing cell data in a row with editors and formatting
« Reply #1 on: August 20, 2014, 12:02:35 pm »
Few points to note:

cellSave is fired when the cell is finally saved, you can't reference the dropdown editor from this event because the editor is destroyed by that time.

1) you could use editor.init or editor.getData callbacks to reference the dropdown editor.

2) Use refreshRow (after making changes in the rowData )
or
updateRow to refresh the entire row.
« Last Edit: August 20, 2014, 12:05:28 pm by paramquery »

urnerbarry

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: setting/changing cell data in a row with editors and formatting
« Reply #2 on: August 21, 2014, 01:23:58 am »
Ok Thanks for your quick reply! I will do some code re-factoring and let you know my end result.