ASP.NET CORE 3 frombody NULL with Bootstrap Table plugins

183 Views Asked by At

I'm trying to do based on this example in the bootstrap table query params. But the parameter I received always NULL, even I already set it before calling backend. I expect the value received should be Supplier. Thanks

view

<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>

controller

[HttpPost]
public string Get_InboxTableData([FromBody] InboxTableData inboxData)
{
  return inboxData.UserType;
}

model

public class InboxTableData
{
    public string UserType { get; set; }
}
1

There are 1 best solutions below

0
On BEST ANSWER

When you call Get_InboxTableData,you will have three parameters,UserType,offset and limit.So you can try to use

public class InboxTableData
    {
        public string UserType { get; set; }
        public int limit { get; set; }
        public int offset { get; set; }

    }

result: enter image description here