ストアのgetNewRecords()関数が長さを返しても機能しないときにボタンを有効/無効にしようとしています。ExtJS 6 - ストアの新しいレコードにバインドされていないプロパティをバインドします。
bind: {
disabled: "{!grid.getStore().getNewRecords().length}"
}
誰かがこれを解決する方法のアイデアを持って?
ストアのgetNewRecords()関数が長さを返しても機能しないときにボタンを有効/無効にしようとしています。ExtJS 6 - ストアの新しいレコードにバインドされていないプロパティをバインドします。
bind: {
disabled: "{!grid.getStore().getNewRecords().length}"
}
誰かがこれを解決する方法のアイデアを持って?
あなたがここでやりたいことは、フレームワークでは現在できません。代わりに、あなたはViewModelにデータ値を作成し、どこでこのようなことが必要が修正する必要があります。
var form = Ext.create("Ext.form.Panel", {
viewModel: {
data: {
newRecords: false
}
},
items: [{
xtype: "textfield",
labelField: "Add Child",
name: "col1",
value: "Teste 123"
}],
tbar: {
xtype: "button",
text: "Add new record",
handler: function() {
var data = this.up("form").getForm().getFieldValues();
var rec = grid.getStore().getAt(0);
data["treeCol"] = rec.childNodes.length + 1;
// setting value, so binding updates
this.lookupViewModel().set('newRecords', true);
rec.appendChild(data);
}
},
bbar: {
xtype: "button",
text: "button to disabled when new records",
bind: {
disabled: "{newRecords}"
}
},
renderTo: Ext.getBody()
});
あなたののviewmodelで式を作成する必要があります。
viewModel: {
formulas: {
hasNewRecords: function (r) {
return this.getView().down("treepanel").getStore().getNewRecords().length > 0;
}
}
}
、あなたはあなたのためにそれを使用することができますバインディング:
bind: {
disabled: "{hasNewRecords}"
}
(おそらく、必要なデータを取得する最良の方法ではありません)。
これを単に行うだけです。お使いのコントローラで
:あなたのビューで
formulas : {
hasNewRecords : {
get : function(get){
var length = get('storeLen') // --> gets the one you set at your controller
return length > 0 ? true : false;
}
}
}
:
me.getView().getViewModel().set('storeLen', store.getNewRecords().length);
あなたのViewModelには、単にこれを行う
bind : {
disabled : '{hasNewRecords}'
}