我有一個劍道組合框由Ajax調用被填充..問題是,當列表只是一個元素..KENDO UI組合框的一個元素多行
,如果我在getNifs有這個(JSON ) 「A08000143」 「A08000142」 組合框將被正確填充..
如果我只是有:"A08000143"
組合將填充像這樣:
"A"
"0"
"8"
"0"
"0"
等..
這是我的jQuery VIEW
$("#divNIF").kendoComboBox({
filter: "contains",
placeholder: "Select Nif...",
dataBound: onDataBound,
dataSource: {
type: "json",
serverFiltering: true,
transport: {
read: {
url: "@Url.Action("GetNifs", "Movimientos")",
}
}
}
});
這是GETNif的功能
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetNifs()
{
List <string> aux_2 = getfromrepository..
if (cliente.test)
{
return Json(aux_2.GetNIFs().First(), JsonRequestBehavior.AllowGet);
}
return Json(cliente.NIF, JsonRequestBehavior.AllowGet);
}
你能證明你收到JSON?我的意思是,如果您在瀏覽器中打開網址,您正在收到什麼? – OnaBai
「A08000143」只有這些 –
JSON需要是一個數組。如果你返回一個字符串,系統得到的是一個字符數組。 – OnaBai