ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: Sunny on July 27, 2015, 04:11:26 pm

Title: Column editor:select type not changing options
Post by: Sunny on July 27, 2015, 04:11:26 pm
Hi,

I am using editor of type select in one of the columns of my grid. Noticed some strange behavior while changing options , provided more details below:

Here is my JSON data returned for the Options:
var csPkList = [{"id":"35170","pack":"XXS","qty":1},{"id":"33125","pack":"XS","qty":1},{"id":"33225","pack":"S","qty":2},{"id":"33325","pack":"M","qty":2}]

I have three columns with dataIndxs (id,pack,qty), having 'id' column as hidden one.
and here is how I defined editor on 'pack' column.
                 
                    dataIndx: 'pack',
                     editor : {
                  type: 'select',
                  labelIndx:'pack',
             valueIndx:'id',
             dataMap: ['qty'],
             options: function (ui) {
               return csPkList;
              }
              }

When I change the select options in 'pack' column from XXS to S,  qty column gets updated from 1 to 2 and it works normally. But when I change options from XXS to XS or S to M, the options are not been changed, they are showing up previous values. Noticed this is because XXS and XS has same qty value, S and M has same qty value.

Can you please advice ?
Title: Re: Column editor:select type not changing options
Post by: paramvir on July 27, 2015, 09:51:13 pm
Could you please also provide colModel and dataModel so that I can check your scenario.

or it would be much appreciated if you could provide a jsfiddle

http://jsfiddle.net/kw77c0sg/2/
Title: Re: Column editor:select type not changing options
Post by: Sunny on July 27, 2015, 10:48:32 pm
Hi ,

I provided scenario in jsfiddle at this link: http://jsfiddle.net/kw77c0sg/5/ (http://jsfiddle.net/kw77c0sg/5/)

Added three columns :Pack,Qty, Id(hidden); Pack column has dropdown editor; To reproduce issue: select 'XXS' option in first row, 'S' option in second row. Try to change from XXS to XS in first row or from 'S' to 'M' in second row, it will go back to previous values.

Hope this helps to understand scenario. Please look and advice solution to resolve this.

Thanks.
Title: Re: Column editor:select type not changing options
Post by: paramvir on July 27, 2015, 11:54:52 pm
Yes, column.editor.dataMap is not working as expected.

I've submitted it to bug log, you would get the fix in next release ( around first week of August )
Title: Re: Column editor:select type not changing options
Post by: Sunny on July 28, 2015, 12:28:42 am
Thank you. Can you make sure the fix will be available in 2.4 version as well ?
Title: Re: Column editor:select type not changing options
Post by: paramvir on July 28, 2015, 01:07:12 pm
you may use this workaround fix.

Code: [Select]
               beforeValidate: function(evt, ui){
                   var newRow = ui.rowList[0].newRow;
                   
                   if(ui.source=='edit' && newRow['id'] ){             
                       ui.source='cedit';
                   }
               },

http://jsfiddle.net/kw77c0sg/7/
Title: Re: Column editor:select type not changing options
Post by: Sunny on July 29, 2015, 01:13:34 am
Thank you, that worked.
Title: Re: Column editor:select type not changing options
Post by: Sunny on September 08, 2015, 09:57:16 pm
Hi,

While I do copy/paste the cells in the column(that has select editor), the dependant columns are not being updated. Can you please advice.

I tried in one of your demo, cascading select lists: http://paramquery.com/pro/demos/edit_select (http://paramquery.com/pro/demos/edit_select), after I selected three different options in column(Shipping Via) for first 3 rows, then I copied 'Speedy Express' in to the other rows which didn't update the 'Shipping Via ID' column.

Attached screenshot.
Title: Re: Column editor:select type not changing options
Post by: paramvir on September 09, 2015, 07:14:08 pm
That is a known limitation of copy/paste w.r.t select lists.

Currently the only workaround is to update the related fields in beforeValidate event:

Code: [Select]
beforeValidate: function(evt, ui){
debugger;
if(ui.source==='paste'){
var rowList = ui.rowList;
for(var i=0;i<rowList.length;i++){
var row = rowList[i],
newRow = row.newRow,
rowData = row.rowData,
oldRow = row.oldRow;
if( newRow.ShipVia ){
newRow.ShipViaId = //lookup for ShipViaId in column.editor.options
oldRow.ShipViaId = rowData.ShipViaId;
}
}
}
},