简体   繁体   English

Ext JS Grid视图中的会话存储代理实现中面临的问题

[英]Facing issue in sessionStorage Proxy implementation in Ext JS Grid view

I just created a Sencha fiddle wherein I have one panel with two grid views inside it. 我刚刚创建了一个Sencha小提琴,其中有一个面板,里面有两个网格视图。 Both Grid views facilitates item selection from left to right and vice-versa. 两个网格视图都有助于从左到右选择项目,反之亦然。 I'm trying to show the selected item from left grid view into right grid view. 我正在尝试将所选项目从左侧网格视图显示为右侧网格视图。 I'm using sessionStorage proxy to hold data while moving items from left to right grid view. 我正在使用sessionStorage代理在从左向右网格视图移动项目时保存数据。 I have to use sessionStorage because my requirement is to persist this selection across the pages. 我必须使用sessionStorage,因为我的要求是在页面上保留此选择。

Sencha fiddle link : https://fiddle.sencha.com/#view/editor&fiddle/2j7u Sencha小提琴链接: https : //fiddle.sencha.com/#view/editor&fiddle/2j7u

Although, I'm not getting any error but my implementation is not working. 虽然,我没有收到任何错误,但是我的实现无法正常工作。 Even the console logs show the correct selection data. 甚至控制台日志也显示正确的选择数据。 But still I'm unable to populate the right grid view. 但是我仍然无法填充正确的网格视图。

One thing I noticed is that in browser debugger under Applcation -> SessionStorage, my sessionStorage object is always null. 我注意到的一件事是,在Applcation-> SessionStorage下的浏览器调试器中,我的sessionStorage对象始终为null。 Don't know why but on console it shows the data. 不知道为什么,但是在控制台上它显示数据。

Console logs from fiddle 小提琴的控制台日志

sessionStorage value from debugger 来自调试器的sessionStorage值

Any pointers would be highly appreciated! 任何指针将不胜感激!

On a side note, the same implementation was working fine with Ext JS 4.2. 附带一提,相同的实现在Ext JS 4.2上运行良好。 But I'm facing issue while migrating to Ext JS 6.5 但是我在迁移到Ext JS 6.5时遇到问题

Thanks, Dhiraj 谢谢,Dhiraj

Further troubleshooting: 进一步的故障排除:

Further, I have updated the same fiddle and was successful to make it work further, by commenting out 'suspendEvents' and 'resumeEvents' for my right grid 'store' --> store2 and 'sessionStore' --> sessionStore2 in tropos.selectDevices.addToSelect method. 此外,我已经更新了相同的小提琴和成功做出进一步努力,通过注释掉“suspendEvents”和“resumeEvents”我的右格“存储” - >商店2和“sessionStore” - > sessionStore2在tropos.selectDevices .addToSelect方法。 Along-with this I figured out that line 'store2.loadPage(1)' in tropos.selectDevices.updateGridViews method was clearing my grid on loading. 与此同时,我发现tropos.selectDevices.updateGridViews方法中的“ store2.loadPage(1)” 正在加载时清除了我的网格。 I tried to avoid that using 'clearOnPageLoad' config setting for store to false. 我试图避免使用'clearOnPageLoad'配置设置将存储设置为false。 But it DIDN'T work so I commented this line to make it work. 但是它没有用,所以我评论了这一行以使其起作用。 Now, although, it works but my main requirement of PRESERVING user selection is still not met because sessionStorage is still not working. 现在,尽管可以正常工作,但是由于sessionStorage仍然无法正常工作,因此仍然无法满足我对PRESERVING用户选择的主要要求。

Updated fiddle: https://fiddle.sencha.com/#view/editor&fiddle/2j7u 更新的提琴: https : //fiddle.sencha.com/#view/editor&fiddle/2j7u

Thanks, Dhiraj 谢谢,Dhiraj

Try this code in your addToSelect : 在您的addToSelect中尝试以下代码:

example.selectDevices.addToSelect = function(storeObj){
    var addRecs = [], newRecs = [],
    store2 = Ext.getCmp('grid2').getStore();

    //********************  
    //I just comment all  *sessionStore2* references because is redundand,
    //store2 is the same as sessionStore2 
    //********************

    //sessionStore2 = Ext.data.StoreManager.lookup('currentlySelectedDevices');
    //store2.suspendEvents();
    //sessionStore2.suspendEvents();

    Ext.each(storeObj,function(record){
        var rec = record.copy();
        rec.phantom = true;
        addRecs.push(rec);
        newRecs.push(record.data.hid);
    });
    example.selectDevices.selectedDeviceIds = example.selectDevices.selectedDeviceIds.concat(newRecs);
    store2.add(addRecs);
    //store2.commitChanges();

    for(i=0; i < store2.data.items.length; i++) {
        console.log("addToSelect: Selected Device Serial [" + i + "] from STORE_2: " + store2.data.items[i].data.hid);
    }
    //sessionStore2.add(addRecs);

    //for(j=0; j < sessionStore2.data.items.length; j++) {
    //    console.log("addToSelect: Selected Device Serial [" + j + "] from SESSION_STORAGE_2: " + sessionStore2.data.items[j].data.hid);
    //}
    //sessionStore2.sync();

    store2.sync();
    //sessionStore2.resumeEvents();

    example.selectDevices.updateGridViews();
};

EDIT: You have to mark the record as phantom = true in order the sync work properly 编辑:您必须将记录标记为phantom = true,以便同步正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM