2024年12月29日 星期日

M-D-D : grid_D的selectionchange event 需加上selections.length > 0的判斷, 以免觸發2次 & 非同步造成顯示資料錯誤

目的: M-D-D - grid_D的selectionchange event 這邊有沒有加上selections.length > 0的判斷

處理說明:

 如果有寫到M-D-D三層式架構的部分,

麻煩檢查一下JS在grid_D的selectionchange event 這邊有沒有加上selections.length > 0的判斷,

如果沒有加這句,再麻煩加一下,以避免跑進去selectionchange兩次,還有非同步造成的顯示資料錯誤的情況,

謝謝!


Ext.getCmp('grid_D2').on("selectionchange", function (self, selections, options) {

        if (selections.length > 0) {

            var gridstore_D = Ext.getCmp('grid_D2_D').store;

            gridstore_D.proxy.url = '../api/B10202API/getGridData_D2_D';

            var np_D = {};

            for (var j = 0; j < MD_DB.aKey_M.length; j++) {

                console.log(selections[0].get("FLINO"))

                np_D[MD_DB.aKey_M[j]] = selections[0].get(MD_DB.aKey_M[j]);

            }

            np_D['CITM'] = selections[0].get('CITM');

            gridstore_D.getProxy().extraParams = np_D;

            Ext.getCmp('grid_D2_D').reloadGridData(false);

        }

        else {

            Ext.getCmp('grid_D2_D').store.removeAll();

            Ext.getCmp('grid_D2_D').getView().refresh();

        }


    });


沒有留言:

張貼留言