目的: V80204B – 將目前 checkboxgroup欄位值(Array),傳送至後端,並處理
處理說明: 1>若非基本型態(string/int/)的欄位值(Array/table/Object),要傳至後端, 均需先轉成 JSON string型態 ,才可當成np的參數值,傳送至後端
*.js
var Tmp_JSONStr = JSON.stringify(Ext.getCmp('chkboxgrp2').getValue()["rb"]);
np["ASN_ARY_JSONStr"]=Tmp_JSONStr;
2> 後端接收時,必需先將 JSON string 型態, 再還回原型態(Array/table/Object)
*.cs
string Tmp_ASN_ARY_JSONStr = nvc["ASN_ARY_JSONStr"];
JArray Tmp_ASN_ARY =
(JArray)JsonConvert.DeserializeObject(Tmp_ASN_ARY_JSONStr, (typeof(JArray)));
1>*.js
var selectedValues = Ext.getCmp('chkboxgrp2').items;
console.log(selectedValues);
var Tmp_ASNAry = []; //var Tmp_Obj={};
//chkboxgrp2 均設為 true
for (var i = 0; i < selectedValues.length; i++) {
selectedValues.items[i].setValue(true);
};
var np = {};
//取得 chkboxgrp2 的勾選欄位值
//將 Array 轉成 JSON字串, 以便傳至後端
var Tmp_JSONStr = JSON.stringify(Ext.getCmp('chkboxgrp2').getValue()["rb"]);
np["ASN_ARY_JSONStr"]=Tmp_JSONStr;
console.log("np['ASN_ARY_JSONStr']: ", np["ASN_ARY_JSONStr"]);
2>*.cs
string Tmp_ASN_ARY_JSONStr = nvc["ASN_ARY_JSONStr"];
JArray Tmp_ASN_ARY = (JArray)JsonConvert.DeserializeObject(Tmp_ASN_ARY_JSONStr, (typeof(JArray)));
string Tmp_ASN_ARY_STR = string.Join(",", Tmp_ASN_ARY);
// "A012,B025" --> 'A012','B025'
Tmp_ASN_ARY_STR = myfunc.AddQuoteStr(Tmp_ASN_ARY_STR);
PS:
1>將checkboxgroup2 的項目均設為 勾選(checked)
{
xtype: 'checkboxgroup',
id: 'chkboxgrp1', // columns: 3,
{
xtype: 'checkboxgroup',
id: 'chkboxgrp1', // columns: 3,
沒有留言:
張貼留言