顯示具有 load 標籤的文章。 顯示所有文章
顯示具有 load 標籤的文章。 顯示所有文章

2023年11月8日 星期三

V80203- 子畫面 – Grid -顯示 Grid子畫面 - store.onload - load - store - proxy - cur_rec

 目的: V80203- 工單需求物料查詢 顯示 Grid子畫面

處理說明: 1>呼叫子畫面函式: Call_V80203B();
                  2>子畫面處理:
    var win = getMyWindow("顯示原始需求物料", sub_BackFlds, sub_BackFlds_Btns);
    Ext.getCmp('sub_Grid').store.getProxy().url = '../../api/V80203BAPI/get_sub_data1',
    Ext.getCmp('sub_Grid').store.getProxy().extraParams = np; //分頁OK,篩選條件OK    
    Ext.getCmp('sub_Grid').store.load();                
                                
    win.show();    





1>V80203.js
{
            xtype: 'button', text: '顯示原始需求物料', id: 'Call_V80203B_Btn',
            listeners: {
                click: function () {
                    //mysuccessalert(" call BatAddBtn_click() ");
                    Call_V80203B();
                }
            }
        },        


2>V80203B.js
function Call_V80203B() {
    //按鈕 : [離開]  
    var sub_BackFlds_Btns = [
        {
            xtype: 'button', text: '離開', id: 'sub_BackFlds_CancelBtn',
            listeners: {
                click: function () {
                    //mysuccessalert("mysub2_取消");
                    var Tmp_win = this.up("window");
                    if (Tmp_win == undefined) {
                        Ext.Msg.alert("取消時未取到Window Object");
                    }
                    this.up("window").close();
                    this.up("window").destroy();
                }
            }
        },
    ];
    
    //sub_ Grid
    var sub_Grid = Ext.create('TMGrid', {
        grid_id: 'sub_Grid',
        columns: sub_B_Columns,
        autoScroll: true,
        flex: 1,
        store: Ext.create('gridstore', { model: sub_B_Fields }),
    });
    console.log("step2.5");

    // [顯示原始需求物料]鈕  - 子畫面欄位
    var sub_BackFlds = [
        {
            type: 'panel', bodyStyle: "background-color:transparent;", border: 0, padding: "5",
            flex: 100,
            //layout: { type: 'vbox', align: 'stretch' }, 
            layout: 'border',
            items: [
                {
                    xtype: 'panel',
                    id: 'sub_panel1',
                    region: 'north',
                    layout: { type: 'hbox', align: 'stretch' },
                    //flex: 0,
                    //border: 1,
                    items: []
                },  //end of panel1                    
                {
                    xtype: 'panel',
                    id: 'sub_panel2',
                    //title: 'sub_panel2',
                    region: 'center',
                    layout: 'fit',
                    //flex: 60,
                    //border: 20,
                    items: [sub_Grid]
                },
            ] // end of   layout: "vbox", padding: "5", items: [
        }  //end of  my_Sub2 , items[{
    ]      //end of  my_Sub2 , items[

    Ext.getCmp('sub_Grid').store.on("load", function (me, records, successful, eOpts) {
        if (successful) {
            console.log("Ext.getCmp('sub_Grid').store", Ext.getCmp('sub_Grid').store);
            console.log("Ext.getCmp('sub_Grid').store.data", Ext.getCmp('sub_Grid').store.data);
        }
    }
    );

    var win = getMyWindow("顯示原始需求物料", sub_BackFlds, sub_BackFlds_Btns);
    //var win = getMyWindow("歸還登記", sub_BackFlds);
    win.width = 800;
    win.heigh = 400;
    var cur_recs = Ext.getCmp('grid_M').getSelectionModel().getSelection();
    if (cur_recs.length == 0) {
        var Tmp_Str = "請先選擇資料";
        mywarnalert(Tmp_Str);
        return ;
    }
    var cur_rec = cur_recs[0];
    var Tmp_AMMNO = cur_rec.data['AMMNO'].toString();
    var np = {};
    np["AMMNO"] = Tmp_AMMNO;    
    var is_Ok = true;
    //顯示 store 的資料
    Ext.getCmp('sub_Grid').store.getProxy().url = '../../api/V80203BAPI/get_sub_data1',
    Ext.getCmp('sub_Grid').store.getProxy().extraParams = np; //分頁OK,篩選條件OK    
    Ext.getCmp('sub_Grid').store.load();               
                                
    win.show();    
    console.log("step6");
} // end of   function LendBtn_click() {

2023年5月18日 星期四

V20302B - 開啟子畫面時, 加入副本人員,但未顯示在畫面 - load() ,store

 目的: V20302B – 開啟子畫面時, 加入副本人員,但未顯示在畫面

處理說明:  1>開啟子畫面時, sub1_Grid2.store 會重新 load()
                   2>[副本人員]加入資料時, sub1_Grid2.store 尚未載入完成  - store load 尚未完成       
                   3>sub1_Grid2.store 載入完成時, 會覆蓋原本的 [副本人員]加入資料
                       --> 以致畫面上未加入資料


1>*.js

function ShowEmailnot6(par_EMPLYIDnot6) {
    Ext.getCmp('sub1_Grid2').store.getProxy().url = '../api/V20302BAPI/getsubData2';
    Ext.getCmp('sub1_Grid2').store.getProxy().extraParams = np; //分頁OK,篩選條件OK    
    Ext.getCmp('sub1_Grid2').store.load();                                                
    //將 CSM_AF@TLS_245 的專案承辦人(以@分隔人員編號) 加入 副本.人員 [姓名][Notes_Email]
    Add_sub1_Grid2(par_EMPLYIDnot6);
    Ext.getCmp('sub1_Grid2').getView().refresh();
   
}

--> store.load();
      Add_sub1_Grid2(par_EMPLYIDnot6);   //store尚未執行完成, 就 加入資料
      //等 store.load() 完成, sub1_Grid2原本加入的資料, 又被清空, 所以畫面無資料

-->改成 load 完成後,再加入資料即可
    store.on('load',function(){
        Add_sub1_Grid2(par_EMPLYIDnot6);
        Ext.getCmp('sub1_Grid2').getView().refresh();
   
    }