2

I have a grid with many columns, and a popup dialogue for adding new records.

I have set deafultValues on data models fields array works fine, now I am trying to reuse that and add this defaults values dynamically from the server.

I have entityName/def available in the server that have the feilds name with default values in it.

I have so many entities, so proxy transform function would be best ? or when creating the the dialogue form window, call the the server to populate the fields ?

I am new to ExtJS and Sencha and I don't have a clear way to both mentioned ways. I am buzzled!!

Any answers, hints are truly appreciated.

Narendra Jadhav
  • 10,052
  • 15
  • 33
  • 44
  • well I think I will have to answer my own question: proxy: { type: 'rest', writer: { transform: function(data, request) { return data; } } } only works after submiting the record with store.sync() hence won't display any modification in the record before that, so I will have to append such values right before creating the dialogue – Mounir Abderrahmani Mar 23 '18 at 09:14
  • Not really sure on why this is problematic. Why is `defaultValue` not sufficient? – Evan Trimboli Mar 24 '18 at 21:26
  • somehow , there is a need to be able to update some default values regularly, so would be better not to hard code them. if it's not possible yet, is there a way to dynamically get the whole model fileds properties as a json aray including default values ? fields: [ { name: 'id', type:int, defaultValue: null} ] – Mounir Abderrahmani Mar 26 '18 at 11:40
  • If the server needs to send the default values as part of the model type, why not just default the values on the server before sending them down, since you already know what the defaults should be? – Evan Trimboli Mar 26 '18 at 12:09
  • well, I have records already in the server and gets populated on the grid, just need to display default values while adding new record from the app ; can you use this https://fiddle.sencha.com/#fiddle/2eug&view/editor – Mounir Abderrahmani Mar 27 '18 at 07:45
  • I solved it . but I am using PUT instead onf POST for the store.sync() function is there a way to avoid this ? createDialog: function (record) { me.isEdit = !!record; if (me.isEdit) { dataRec = dataStore.getById(record.get('gid')); } else { if (defStore){ phantomrec = defStore.data.items[0]; dataRec = dataStore.insert(0, phantomrec)[0]; }else dataRec = dataStore.insert(0, {})[0]; } }, – Mounir Abderrahmani Mar 28 '18 at 10:48

0 Answers0