1
因此,即時通訊使用2個下拉列表,其中第二個應該從服務器根據第一個選定的項目從服務器獲取項目,問題是,這隻能在第一個timei單擊子droplist,這意味着如果我更改父列表項,子項仍將顯示以前的項目。什麼是我的劍道級聯下拉列表失敗。只有第一次工作
下面是一些代碼:
kendofi=function (index){
//kendofi select boxes
$("#dynamicFormLinha"+index).kendoDropDownList({
name:"formularios",
optionLabel: "Formulario",
dataTextField: "name",
dataValueField: "id",
dataSource: {
type: "json",
serverFiltering: true,
transport: {
read: "${pageContext.request.contextPath}" + "/newlayout/mySearchesDynForms.do"
},
schema: {
model: {
fields: {
id: { type: "number" },
name: { type: "string" }
}
}
}
}
}).data("kendoDropDownList");
$("#campoFormLinha"+index).kendoDropDownList({
autoBind:false,
name:"campos",
optionLabel: "Campo",
dataTextField: "name",
dataValueField: "id",
dataSource: {
type: "json",
serverFiltering:true,
transport: {
read:{
url:"${pageContext.request.contextPath}" + "/newlayout/mySearchesFormFieds.do",
data:function(){
return {formId: $("#dynamicFormLinha"+index).val()
};
}
}
}
},
cascadeFrom: "dynamicFormLinha1",
schema: {
model: {
fields: {
id: { type: "number" },
name: { type: "string" }
}
}
}
}).data("kendoDropDownList");
而這裏的每一個下拉列表中的Java春天控制器類方法:
@RequestMapping(method = RequestMethod.GET, value="/newlayout/mySearchesDynForms")
public @ResponseBody
DynamicFormTemplateDPO[] getForms(){
return dynamicFormService.getAllActiveFormTemplatesForPresentation();
}
@RequestMapping(method = RequestMethod.GET, value="/newlayout/mySearchesFormFieds")
public @ResponseBody
DynamicFieldTemplateDPO[] getFormFields(@RequestParam long formId){
return dynamicFormService.getFormFields(formId);
}
這些都返回JSON數據中,父子返回此:
[{"id":1,"name":"drcie"},{"id":2,"name":"edp"},{"id":3,"name":"pt"}]
然後,所選的id將用作getFormFields方法中的formId參數d,返回是這樣的:
[{"id":1,"name":"Nome","type":"STRING"},{"id":2,"name":"Morada","type":"STRING"},{"id":3,"name":"Contribuinte","type":"STRING"},{"id":4,"name":"Multibanco","type":"STRING"}]
這裏的kendofi方法,是因爲這些部件是表內,您可以在保持部件的功能添加新的錶行。
對不起,我遲到的反應,我想我設法讓它通過刪除name屬性,這是造成一些問題的工作......但生病標記給您迴應,因爲我應該做了我自己的回答.... – Maxrunner