나는 extjs4에서 일하고있다. 코드가있는 항목으로 표가있는보기 :extjs4에서 삭제시 그리드에서 레코드를 삭제하는 방법
{
margin : '10 0 5 100',
xtype : 'grid',
id : 'g3',
//title : 'Educational Details',
store:'qb.qbquestionoptionStore',
columns : [ {
text : 'questionId',
dataIndex : 'questionId',
flex : 1
},
{
text : 'category',
dataIndex : 'category',
flex : 1
}, {
text : 'Answer',
dataIndex : 'isAnswer',
flex : 2.5
},
{
header : 'Remove',
renderer : function(val) {
return '<a href="#" id="remove">Remove</a>';
},
}
따라서 링크를 클릭하면 해당 항목이 데이터베이스에서 삭제됩니다. 그러나 그리드는 여전히 삭제 된 항목을 보여줍니다. 컨트롤러에서 나는 그것을위한 코드가있다.
deleterow:function(cmp)
{
cmp.mon(cmp.getEl(),'click',function(event,target)
{
if(target.id=='remove')
{
// alert("hello");
listview=Ext.getCmp('g3');
listview.on({
itemClick: function(dv, record, item, index, e,opts)
{
liststore=this.getStore('qb.qbquestioncomplexityStore').sync();
liststore.load({
params:{
id:record.data.id,
questionId:record.data.questionId
}
});
console.log(record);
console.log(" Id is "+record.data.id);
var shopCart=Ext.create('Balaee.model.qb.qbquestioncomplexityModel',
{
id:record.data.id,
questionId:record.data.questionId
});
Ext.Msg.confirm('Confirm to delete', 'Want to delete record?', function (button)
{
if (button == 'yes')
{
shopCart.destroy();
}
}); }
}); }
},this,{delegate:"a"});
},
그리드에서 레코드를 삭제하는 방법.
고맙습니다 ... 내가 사용하는 경우 "record.store.remove (기록) record.store.sync(); shopCart.destroy를();" 그게 나에게 오류를 준다 Uncaught TypeError : null의 'sync'메서드를 호출 할 수 없다 – user1722857
@ user1722857 죄송합니다. 내 잘못입니다. 나는 내 대답을 편집했다. – sra
고맙습니다 답장을드립니다 .... 나는 당신이 제안한대로 다음과 같습니다. 하지만 이제는 오류가 발생했습니다. "Uncaught Ext.data.proxy.Server.buildUrl() : ServerProxy를 사용하고 있지만 URL을 제공하지 않았습니다." 모델의 프록시를 사용하고 있습니다. 그래서 내가해야 할 변화 – user1722857