javascript - Extjs 6 combobox values and display values not displaying correctly when setting values dynamically per row -


oof long title.

in current project have grid holds set of workshop records. each of these workshops there set of rates apply given workshop.

my goal display combobox each row shows rates specific work shop.

i've got a prototype works part on sencha fiddle, there's off how selection values being created:

ext.define('rates',{     extend: 'ext.data.store',     storeid: 'rates',     fields: [         'ratearray'     ],     data:[         {             workshop: 'test workshop 1',             ratearray: {                 rate1: {show: "yes", rate: "105", description: "standard registration"},                 rate3: {show: "yes", rate: "125", description: "non-member rate"},                 rate4: {show: "yes", rate: "44", description: "price sk tester"}             }         },         {             workshop: 'test workshop 2',             ratearray: {                 rate1: {show: "yes", rate: "10", description: "standard registration"},                 rate2: {show: "yes", rate: "25", description: "non-member registration"}             }         }     ] });   ext.define('mygrid',{     extend: 'ext.grid.panel',      title: 'test combo box unique values per row',      renderto: ext.getbody(),      columns:[         {             xtype: 'gridcolumn',             text: 'name',             dataindex: 'workshop',             flex: 1         },         {             xtype: 'widgetcolumn',             text: 'price',             width: 200,             widget:{                 xtype: 'combo',                 store: [                     // ['test','worked']                 ]             },             onwidgetattach: function (column, widget, record){                 var selections = [];                 ext.object.each(record.get('ratearray'), function (rate, value, obj){                     var desc = ext.string.format("${0}: {1}", value.rate, value.description);                     // according docs section on combobox stores use 2 dimensional arrays                     // think pushing way make display value of combobox                     // description , value stored rate.                      selections.push([rate, desc]);                 });                 console.log(selections);                 widget.getstore().add(selections);             }         }      ] });  ext.application({     name : 'fiddle',      launch : function() {         var store = ext.create('rates');         ext.create('mygrid',{store: store});     } }); 

in grid widget i'm using combobox i'm using onwidgetattach method inspect current row's record, assemble rate data record 2 dimensional array, , setting widget's store.

when @ sencha docs section on using 2 dimensional array store, states:

for multi-dimensional array, value in index 0 of each item assumed combo valuefield, while value @ index 1 assumed combo displayfield.

given that, expect combo box show assembled description (e.g. "$150: standard registration") , use object key actual stored value (e.g. "rate1").

what i'm seeing display value rate , i'm not sure how sencha generates combobox selections see how selection being rendered out.

is assumption how 2-dimensionally array gets converted store wrong?

well, question suffering xy problem. because want following:

you want create decent store combo, using well-defined model meaningful column names have in "ratearray", define displayfield , valuefield accordingly, , in onwidgetattach, stuff "ratearray" object store using setdata.

sth. along lines of

xtype: 'widgetcolumn', text: 'price', width: 200, widget:{     xtype: 'combo',     store: ext.create('ext.data.store',{         fields:['rate','description','show']         filters:[{property:'show',value:"yes"}]     }),     displayfield:'description',     valuefield:'rate',     onwidgetattach: function (column, widget, record){         widget.getstore().setdata(record.get("ratearray"));     } }, 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -