-
3 Dec 2012 4:07 AM #41
http://docs.sencha.com/ext-js/4-1/#!...-totalPropertyWhere should I set totalProperty?
You have to set totalProperty in reader, so you can change it in DynamicReader class.
I didn't test this code but should works.Code:proxy: { reader: Ext.create('Ext.ux.data.reader.DynamicReader', { totalProperty: 'yourValue' }), type: 'rest', url: me.url } or proxy: { reader: { type: 'dynamicReader', totalProperty: 'yourValue' }, type: 'rest', url: me.url }
-
4 Dec 2012 2:28 AM #42
This isn't working, still getting all rows in all pages
.
-
12 Dec 2012 5:46 AM #43
Any idea? I tried giving some value directly for totalProperty, not working
.
-
13 Dec 2012 4:04 AM #44
So it seems totalProperty SHOULD be given from the JSON response, but reader in DynamicGrid.js doesn't get that value, anyone know how I should set it with this plugin?
-
17 Dec 2012 8:21 AM #45
-
18 Dec 2012 3:36 AM #46
-
18 Dec 2012 9:31 AM #47
Hi,
The most logical thing would be to modify the DynamicGrid class to use the plugin within the 'apply' function as below:
Unfortunately this does not appear to work.Code:Ext.define('Ext.ux.grid.DynamicGrid', { extend: 'Ext.grid.Panel', alias: 'widget.dynamicGrid', alternateClassName: 'Ext.grid.DynamicGrid', requires: [ 'Ext.ux.data.reader.DynamicReader' 'Ext.grid.plugin.BufferedRenderer' ], // URL used for request to the server. Required url: '', initComponent: function() { //console.log('DynamicGrid initComponent!'); var me = this; if (me.url == '') { Ext.Error.raise('url parameter is empty! You have to set proper url to get data form server.'); } else { Ext.applyIf(me, { columns: [], forceFit: true, store: Ext.create('Ext.data.Store', { // Fields have to be set as empty array. Without this Ext will not create dynamic model. fields: [], // After loading data grid have to reconfigure columns with dynamic created columns // in Ext.ux.data.reader.DynamicReader listeners: { 'metachange': function(store, meta) { me.reconfigure(store, meta.columns); } }, autoLoad: true, remoteSort: false, remoteFilter: false, remoteGroup: false, proxy: { reader: 'dynamicReader', type: 'rest', url: me.url } }) plugins: 'bufferedrenderer' }); } me.callParent(arguments); } });
-
19 Dec 2012 12:07 AM #48
Need help
Need help
Can someone help me what do I need to modify in DynamicReader.js on readRecord function.
I already put root : 'Data' on the Ext.ux.data.reader.DynamicReader and didnt work.
The ./data.js work fine and I found out the Json Format is like this [{}, {}, {} ], but i need like this {"Data":[{},{},{}]}
{"Data":[{"EmployeeID":1,"UserName":"dexter","Password":"96e79218965eb72c92a549dd5a330112","ComparePassword":"96e79218965eb72c92a549dd5a330112","TimeSheet":null,"FirstName":"Dexter","MiddleName":"","LastName":"Uy"},{"EmployeeID":2,"UserName":"dewey","Password":"96e79218965eb72c92a549dd5a330112","ComparePassword":"96e79218965eb72c92a549dd5a330112","TimeSheet":null,"FirstName":"Dewey","MiddleName":"","LastName":"Uy"},{"EmployeeID":3,"UserName":"dominic","Password":"96e79218965eb72c92a549dd5a330112","ComparePassword":"96e79218965eb72c92a549dd5a330112","TimeSheet":null,"FirstName":"Dominic","MiddleName":"","LastName":"Uy"},{"EmployeeID":4,"UserName":"diane","Password":"96e79218965eb72c92a549dd5a330112","ComparePassword":"96e79218965eb72c92a549dd5a330112","TimeSheet":null,"FirstName":"Diane","MiddleName":"","LastName":"Uy"},{"EmployeeID":5,"UserName":"camile","Password":"96e79218965eb72c92a549dd5a330112","ComparePassword":"96e79218965eb72c92a549dd5a330112","TimeSheet":null,"FirstName":"Camile","MiddleName":"","LastName":"Uy"}],"total":5}
-
19 Dec 2012 2:48 AM #49
You can either change your JSON response to return without root or try in DynamciReader.js like,
Hope this will work.Code:readRecords: function(datastr) { var data = {}; if(datastr.Data){ data = datastr.Data; } if (data.length > 0) { . . . return this.callParent([data]); }
-
20 Dec 2012 10:08 PM #50
Please Help
Please Help
Hi
When I use this kind of Code the Code will work correctly
My Problem the Store wont fire the metadata change. Another problem is we are required us to use Sencha Architect. Therefore it is hard to manipulate code.Code:Ext.define('Ext.ux.data.reader.DynamicReader', { extend: 'Ext.data.reader.Json', alias: 'reader.dynamicReader', alternateClassName: 'Ext.data.reader.DynamicReader', paramsAsHash: true, messageProperty: 'message', totalProperty: 'total', successProperty: 'success', root : 'Data', type : 'json', readRecords: function(data) { if (data.Data.length > 0) { var item = data.Data[0]; var fields = new Array(); var columns = new Array(); var p; for (p in item) { if (p && p != undefined) { // floatOrString type is only an option // You can make your own data type for more complex situations // or set it just to 'string' fields.push({name: p, type: 'floatOrString'}); columns.push({text: p, dataIndex: p}); } } data.metaData = { fields: fields, columns: columns }; } return this.callParent([data]); } });
The Code Produce by Architect is like this
Can someone help me to find the solution?Code:Ext.define('Desktop.store.DynamicStore', { extend: 'Ext.data.Store', constructor: function(cfg) { var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: true, storeId: 'MyJsonStore1', proxy: { type: 'ajax', url: 'http://localhost/iRelySuite/Employee/Dynamic?value=Employee', reader: { type: 'json', readRecords: function(data) { alert("reading"); if (data.Data.length > 0) { var item = data.Data[0]; var fields = new Array(); var columns = new Array(); var p; for (p in item) { if (p && p != undefined) { // floatOrString type is only an option // You can make your own data type for more complex situations // or set it just to 'string' fields.push({name: p, type: 'string'}); columns.push({text: p, dataIndex: p}); alert(p); } } data.metaData = { fields: fields, columns: columns }; alert(data.metaData.fields[0]); } return this.callParent([data]); }, paramsAsHash: true, messageProperty: 'message', root: 'Data' } }, listeners: { metachange: { fn: me.MetaChange, scope: me } }, fields: [ { name: 'field7' } ] }, cfg)]); }, MetaChange: function(store, meta, options) { alert("Metachange"); alert(meta.columns[0]); me.reconfigure(store, meta.columns); } });
I really dont understand what is the meaning of this me.callParent() and also return this.callParent([data]);
Thanks in advance


Reply With Quote
