0
に応じて、特定の値のみを非表示にする)次のようになりますのようDataTableのエディタ() - 表示/私は(2つの私のDataTableエディタインスタンス内の選択フィールドと作業依存を持って最初に選択した値
editor.dependent('account_sectors2.sector_id', function (val) {
return (val == null) ?
{ hide: ['account_sectors3.sector_id'] } :
{ show: ['account_sectors3.sector_id'] };
});
今すぐ、最初の選択の値を選択するたびに(11,23,31-33、...)私は2番目の選択肢の値をすべて取得します。しかし、私が望むのは、最初に選択された値に応じて第2の選択値の特定の値のみを表示することです。このよう
値:
11
|_111
|_112
|_113
|_114
23
|_236
31-33
|_311
|_312
|_315
|_325
|_332
|_334
|_335
はどのようにこれを行うことができますか?コールバックを行うことも可能である依存()関数内で
{
"data":[
...
],
"options":{
"account_sectors2.sector_id":[
{
"label":"Agriculture, Forestry, Fishing and Hunting",
"value":"11"
},
{
"label":"Construction",
"value":"23"
},
{
"label":"Manufacturing",
"value":"31-33"
},
{
"label":"Mining, Quarrying, and Oil and Gas Extraction",
"value":"21"
},
{
"label":"Utilities",
"value":"22"
}
],
"account_sectors3.sector_id":[
{
"label":"Animal Production and Aquaculture",
"value":"112"
},
{
"label":"Apparel Manufacturing",
"value":"315"
},
{
"label":"Beverage and Tobacco Product Manufacturing",
"value":"312"
},
{
"label":"Chemical Manufacturing",
"value":"325"
},
{
"label":"Computer and Electronic Product Manufacturing",
"value":"334"
},
{
"label":"Construction of Buildings",
"value":"236"
},
{
"label":"Crop Production",
"value":"111"
},
{
"label":"Electrical Equipment, Appliance, and Component Manufacturing",
"value":"335"
},
{
"label":"Fabricated Metal Product Manufacturing",
"value":"332"
},
{
"label":"Fishing, Hunting and Trapping",
"value":"114"
},
{
"label":"Food Manufacturing",
"value":"311"
},
{
"label":"Forestry and Logging",
"value":"113"
}
]
},
"files":[
],
"draw":1,
"recordsTotal":"20",
"recordsFiltered":"20"
}
:よう
datatable.phpは
Field::inst('account_sectors2.sector_id')
->options('sectors2', 'NaicsCode2', 'NaicsTitle2'),
Field::inst('sectors2.NaicsTitle2'),
Field::inst('account_sectors3.sector_id')
->options('sectors3', 'NaicsCode3', 'NaicsTitle3' }
),
Field::inst('sectors3.NaicsTitle3')
返されるJSONに見えます。私はそれが行く方法だと思います...しかし、私はそれを実装するために苦労しています。
editor.dependent('account_sectors2.sector_id', function (val, data, callback) {
$.ajax({
url: 'datatable.php',
dataType: 'json',
success: function (json) {
callback(json);
}
});
});