【发布时间】:2015-07-26 23:20:31
【问题描述】:
bootstrap datatable plugin 有问题我的班级看起来像这样:
型号
public class Class1 {
public string EmployeeID { get; set; }
public string FirstName { get; set; }
public Position Position { get; set; }
public Class1 GetEmployees()
{
return this;
}
}
public class Position {
public string PositionID { get; set; }
public string PositionName { get; set; }
//Other functions below
}
控制器
public JsonResult GetEmployees()
{
return Json(new Class1().GetEmployees(), JsonRequestBehavior.AllowGet);
}
HTML
<table id="tblLeaveCredits"
data-url="/Employees/GetEmployees"
data-toggle="table"
data-search="true"
data-click-to-select="true"
data-select-item-name="rdoSelectedItem"
data-cache="false">
<thead>
<tr>
<th data-field="state" data-radio="true"></th>
<th data-field="FirstName" data-sortable="true">Description</th>
<th data-field="Position.PositionName" data-sortable="true">Available</th>
</tr>
</thead>
</table>
我的问题是,如何从 Json 返回中获取 Position 类的数据并将其显示为数据表中的字段?
【问题讨论】:
-
在bootstrap page 上我找不到数据表。您在使用插件吗?可以链接到它吗?
-
嗨!我正在使用来自 wenzhixin.net.cn 的引导表。这是链接bootstrap-table.wenzhixin.net.cn
-
无论是在source code 还是docs 的bootstrap-table.wenzhixin.net.cn 插件中,我都找不到绑定嵌套json 对象的选项。因此,您可以考虑将其扁平化 server side 或 client side。我没有测试过任何一个答案。
标签: c# json twitter-bootstrap