extjs - Sencha Touch. NestedList move, insert, remove items -
my question how move, insert , remove items in nestedlist have nestedlist this:
// model ext.define('myapp.model.comments', { extend: 'ext.data.model', config: { fields: [ {name: 'text', type: 'string'} ] } }); // nestedlist ext.define('myapp.view.comments', { requires: [ 'ext.data.treestore' ], config: { id: 'comments', store: { type: 'tree', root: {}, model: 'myapp.model.comments', proxy: { type: 'ajax', actionmethods: {read: 'post'}, url: './comments.php', timeout: 4000, enablepagingparams: false, extraparams: { action: 'get-comments' } } }, displayfield: 'text', detailcard: { xtype: 'container', layout: 'vbox', items: [ { id: 'comment-text-field', flex: 1 } ] }, listeners: { leafitemtap: function(el, list, index, target, record) { var detailcard = el.getdetailcard(), text = record.data.text, commentfield = detailcard.query("#comment-text-field"); var texthtml = '<b>text: </b>' + text; if (commentfield) { commentfield[0].sethtml(texthtml); } }, destroy: function(el) { el.getdetailcard().destroy(); } } } }); // './comments.php' response [ { "text": "new comments", "children": [ { "text": "nestedlist provides miller column interface navigate between", "leaf": true }, { "text": "the absolute bottom position of component; must valid css length value", "leaf": true } ] }, { "text": "checked comments", "children": [ { "text": "whether or not component absolutely centered inside container", "leaf": true }, { "text": "component absolutely centered inside container", "leaf": true }, { "text": "more comments", "leaf": true } ] } ]
it works fine need move, remove , add items in nestedlist. f.e. when open 1 of "new comments" (leaf item opened , leafitemtap fired), opened item should removed "new comments" , inserted "checked comments".
i see 2 ways it:
- send request update comments.php response , update store via sencha functionality
- send request update comments.php response , reload comments.php each time when items clicked update nestedlist
of course 1st way better, have no idea how @ least 1 of them.
hope me, thsnk's!
well, looks there no convenient way that. here comment on official forum: http://www.sencha.com/forum/showthread.php?205097-how-to-create-a-nested-list-with-dynamic-loading-of-each-node
Comments
Post a Comment