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

2022年7月20日 星期三

V120502 - 加入本機印表機選項 (非主機端的印表機)

 


1>ComboBox 加入本地印表機選項 :
     *.js

{  //挑選印表機
xtype: "fieldcontainer", fieldLabel: "印表機", labelWidth: 60, layout: "hbox", flex: 15,
items: [
{
xtype: "combobox", id: "sub_PRINTER", name: "sub_PRINTER", width:250, padding: "0 4 0 0",
store: store_PRNLIST,
emptyText: "--請選擇--", displayField: "Name", valueField: "Value"
queryMode: "local"                                                  
},
]
},  // end of 挑選印表機

var np = {};
    Ext.Ajax.request({
        method: "POST",
        url: '../../api/V120502API/Get_PRNLIST',
        params: np,
        async: false,
        success: function (response, opts) {            
            console.log("0 response=", response);
            console.log("0 response.responseText=", response.responseText);            
            var Tmp_Obj = Ext.decode(response.responseText);
            //Ext.decode Array of Object  也可解碼 ,  Tmp_Obj : Array [{},{},..]
            var Tmp_Name, Tmp_Value;
            var cur_rec = {};
            for (i = 0; i <Tmp_Obj.length; i++)
    {        
                Tmp_Name = Tmp_Obj[i]["Key"];
                Tmp_Value = Tmp_Obj[i]["Value"];
                cur_rec = { Name: Tmp_Name, Value: Tmp_Value };
                //cur_rec = { Name: Tmp_Obj[i]["Key"], Value: Tmp_Obj[i]["Value"] };
                console.log("6  cur_rec= ", cur_rec);
                store_PRNLIST.add(cur_rec);                        
    }

//不可再  store_PRNLIST.load();  --> 會載入原始的 data , 後來新增item, 不會顯示


2>*.cs  c# 呼叫 get_PRNLIST() 取得 主機端的 印表機選項
 [HttpPost]
public HttpResponseMessage get_PRNLIST()
{
           String Tmp_PRNNM;
            String Tmp_RtnStr = "";
            for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                Tmp_PRNNM = PrinterSettings.InstalledPrinters[i];
                PRNLIST.Add(Tmp_PRNNM, i.ToString());
                Tmp_RtnStr = Tmp_RtnStr
                                     + "{Key:" + myfunc.AA(Tmp_PRNNM) + ",Value:" + i.ToString() + "},";
             }        
             if (Tmp_RtnStr.Length > 0)
            {
                Tmp_RtnStr=Tmp_RtnStr.Substring(0, Tmp_RtnStr.Length-1);
                Tmp_RtnStr = "[" + Tmp_RtnStr + "]";
                    };    
            var response = this.Request.CreateResponse();
            response.Content = new StringContent(Tmp_RtnStr);    // 回應內容
            return response;        
}






2022年7月18日 星期一

V120502 - ComboBox 加入選項 - ComboBox 加入本機 [印表機選項]

 


Combobox: 的選項,必需由 store提供

        //標籤ComboBox的下拉表單欄位值
        var store_LABELH = Ext.create("Ext.data.Store", {
            fields: ["Name", "Value"],
            data: [
                { Name: "40", Value: 40 },
                { Name: "60", Value: 60 },
                { Name: "70", Value: 70 },
            ]
        });


 {  //標籤高度
       xtype: "fieldcontainer", fieldLabel: "標籤高度", labelWidth: 60, layout: "hbox", flex: 10,
       items: [
                    {
          xtype: "combobox", id: "sub_LABELH", name: "sub_LABELH", width: 110, padding: "0 4 0 0",
          store: store_LABELH,   
          emptyText: "--請選擇--", displayField: "Name", valueField: "Value", queryMode: "local"},
                    ]
                            },  // end of 標籤高度