MVC 용 Kendo DropdownList를 사용하여 DropdownList에서이 데이터를 허용하지 않는 이유를 확인하려고합니다.검도 UI 드롭 다운 목록에서 JSON 데이터를 허용하지 않습니까?
"{\"표 \ ": [{\"ORG_ID \ "265498 \"COMPORGID
는 SQL 동작에서 원시 데이터
@(Html.Kendo().DropDownList() .Name("CompanyList") //The name of the DropDownList is mandatory. It specifies the "id" attribute of the widget. .DataTextField("Table") .DataValueField("COM_NAME") .DataSource(source => { source.Custom() // Read(read => .Type("json") .Transport(transport => { transport.Read("GetallCompanies", "Home"); }) .ServerFiltering(true); //If true, the DataSource will not filter the data on the client. }) .SelectedIndex(0) //Select the first item.
)는이 형식을 갖는다 \ "COM_NAME \": \ "ABC Rentals \"}, \ "ORG_ID \": 164929, \ "COMPORGID \ : 239698 \"COM_NAME \ ": \"Asbury Machine Shop \ "} ]} "
Kendo docs 및 기타 SO 사례를 참조하십시오. JSON을 유효성 검사기 도구에 넣으십시오. 올바르게 형식이 지정되어 있습니다.
페이지에서 드롭 다운에 왼쪽 중괄호가 있습니다 (상단 항목으로, 클릭 할 때 수십 개의 : 정의되지 않음).
DataTextField는 JSON 배열의 "테이블"때문에 "테이블"이라고 불렀지 만 COM_NAME으로 설정되었습니다. 컨트롤러 방법,
[HttpGet]
public JsonResult GetallCompanies()
{
var ddx = CompInfo.GetAllCompanies(); //returns dataset
string thedata = JsonConvert.SerializeObject(ddx);
return Json(thedata, JsonRequestBehavior.AllowGet);
}
''CompInfo.GetAllCompanies()'에서 무엇을 얻을 ddx'는 무엇입니까? – Shai
원래 "Table \"로 시작하는 JSON이 반환되었지만 답변에 따라 SerializeObject를 제거하기 위해 바뀌 었으므로 지금은 단일 Table [0]과 많은 행을 가진 DataSet을 반환합니다. – rogersbra1