ASP.NET CORE 3 frombody NULL with Bootstrap Table 插件
ASP.NET CORE 3 frombody NULL with Bootstrap Table plugins
我正在尝试基于 bootstrap table 中的这个示例
query params。但是我收到的参数总是NULL,即使我在调用后端之前已经设置了它。我预计收到的值应该是 Supplier。谢谢
查看
<table id="supplier-inbox-table" class="table table-bordered table-striped text-center bootstrap-table"
data-toggle="table"
data-query-params="InboxTableParams"
data-url="/AppService/Get_InboxTableData"
data-method="post"
data-pagination="true"
data-side-pagination="server">
<thead class="thead-dark">
<tr>
<th data-checkbox="true"></th>
<th data-field="ID" data-sortable="true">ID No</th>
<th data-field="Customer" data-sortable="true">Customer</th>
<th data-field="StoreCode" data-sortable="true">Store Code</th>
</tr>
</thead>
<script>
function InboxTableParams(params) {
params.UserType = 'Supplier';
return params;
}
</script>
控制器
[HttpPost]
public string Get_InboxTableData([FromBody] InboxTableData inboxData)
{
return inboxData.UserType;
}
型号
public class InboxTableData
{
public string UserType { get; set; }
}
当你调用Get_InboxTableData时,你会得到三个参数,UserType,offset and limit
。所以你可以尝试使用
public class InboxTableData
{
public string UserType { get; set; }
public int limit { get; set; }
public int offset { get; set; }
}
结果:
我正在尝试基于 bootstrap table 中的这个示例 query params。但是我收到的参数总是NULL,即使我在调用后端之前已经设置了它。我预计收到的值应该是 Supplier。谢谢
查看
<table id="supplier-inbox-table" class="table table-bordered table-striped text-center bootstrap-table"
data-toggle="table"
data-query-params="InboxTableParams"
data-url="/AppService/Get_InboxTableData"
data-method="post"
data-pagination="true"
data-side-pagination="server">
<thead class="thead-dark">
<tr>
<th data-checkbox="true"></th>
<th data-field="ID" data-sortable="true">ID No</th>
<th data-field="Customer" data-sortable="true">Customer</th>
<th data-field="StoreCode" data-sortable="true">Store Code</th>
</tr>
</thead>
<script>
function InboxTableParams(params) {
params.UserType = 'Supplier';
return params;
}
</script>
控制器
[HttpPost]
public string Get_InboxTableData([FromBody] InboxTableData inboxData)
{
return inboxData.UserType;
}
型号
public class InboxTableData
{
public string UserType { get; set; }
}
当你调用Get_InboxTableData时,你会得到三个参数,UserType,offset and limit
。所以你可以尝试使用
public class InboxTableData
{
public string UserType { get; set; }
public int limit { get; set; }
public int offset { get; set; }
}
结果: