I am new to jscript and am changing the code in a C# razor page. the data model have the variable AgvId in the model, but when I try and use it in the datatable column I get the following error. enter image description here I think the name is not correct, but do not understand how to find what the correct name is to use. I hope someone with more experience can give me some help.
Thank you in advance for your help.
var table = $('#orders').DataTable({
"processing": false, // for show progress bar
"serverSide": false, // for process server side
"filter": true, // this is for disable filter (search box)
"orderMulti": false, // for disable multiple column at once
"lengthMenu": [[20, 50, -1], [20, 50, "All"]],
"pagingType": "simple",
"ajax": {
"url": "/Orders/OrderList/data", // for client side /LoadDataAll
"type": "GET", // for client side "GET"
"datatype": "json"
},
"select": 'single',
"columns": [
{ "data": "created", "render": DateRenderer, "autoWidth": true },
{ "data": "wmsid", "name": "WMSID", "autoWidth": true },
{ "data": "index", "name": "OrderID", "autoWidth": true },
{ "data": "pick.name", "name": "Pick", "autoWidth": true },
{ "data": "drop.name", "name": "Drop", "autoWidth": true },
//{ "data": "sequence", "name": "Sequence", "autoWidth": true },
{ "data": "agvid", "name": "AgvID", "autoWidth": true },
{ "data": "status", "name": "Status", "autoWidth": true },
//{ "data": "priority", "name": "Priority", "autoWidth": true },
{ "data": "null", "render": ModifyRenderer, "orderable": false },
{ "data": "null", "render": CancelRenderer, "orderable": false },
//{ "data": "null", "render": DeleteRenderer, "orderable": false },
]
});
Here is the web page table for the web page
<table width="99%">
<tbody>
<tr>
<td valign="top" width="99%">
<input id="orderidcurrent" name="orderidcurrenthidden" value="0" hidden />
<div class="container-fluid">
<table id="orders" class="display">
<thead>
<tr class="text-condensed">
<th>Created</th>
<th>ID WMS</th>
<th>ID SM</th>
<th>Pick</th>
<th>Drop</th>
@*<th>Sequence</th>*@
<th>AGVID</th>
<th>Status</th>
@*<th>Priority</th>*@
<th></th>
<th></th>
<th></th> @*add back in if using buttons, TAF, 11/21/22*@
</tr>
</thead>
</table>
</div>
</td>
</tr>
</tbody>
</table>
I have added the OnGet method for additional information.
public JsonResult OnGet(string strRouteText, string orderid,string pick = null, String drop = null)
{
if (OnPostActive)
{
ShowStartButton = false;
_OnPostOneShot = true;
}
else
{
ShowStartButton = true;
if (_OnPostOneShot == true)
{
//Redirect("/Orders/OrderList/");
_OnPostOneShot = false;
}
}
if (string.IsNullOrEmpty(strRouteText))
{
return null;
}
else if (strRouteText == "data")
{
return LoadData();
}
else if (strRouteText.StartsWith("conn"))
{
IpcControlStatus objIpcControlStatus = _infAgvSystem.GetStatus();
bool bConnected = _infAgvSystem.Connected;
if (bConnected)
{
return new JsonResult("true");
}
else
{
return new JsonResult("false");
}
}
else if (strRouteText.StartsWith("ids"))
{
List<Order> listOrders = _infAgvSystem.GetOrders();
List<string> listIDs = new List<string>();
foreach (Order objOrder in listOrders)
{
listIDs.Add(objOrder.WMSID);
}
return new JsonResult(listIDs.ToList());
}
else if (strRouteText.StartsWith("picks"))
{
List<Station> listStations = _infAgvSystem.GetStations();
List<Station> listPickStations = listStations.FindAll(x => (x.Type == "P") || (x.Type == "B"));
List<string> listPicks = new List<string>();
foreach (Station objStation in listPickStations)
{
listPicks.Add(objStation.Name);
}
PickList = listPicks;
return new JsonResult(listPicks.ToList());
}
else if (strRouteText.StartsWith("drops"))
{
List<Station> listStations = _infAgvSystem.GetStations();
List<Station> listDropStations = listStations.FindAll(x => (x.Type == "D") || (x.Type == "B"));
List<string> listDrops = new List<string>();
foreach (Station objStation in listDropStations)
{
listDrops.Add(objStation.Name);
}
DropList = listDrops;
return new JsonResult(listDrops.ToList());
}
else if (strRouteText.StartsWith("priorities"))
{
List<AACPriority> listAACPriority = Enum.GetValues(typeof(AACPriority)).Cast<AACPriority>().ToList();
List<string> listPriorities = new List<string>();
foreach(AACPriority eAACPriority in listAACPriority)
{
if (!listPriorities.Contains(eAACPriority.ToString()))
listPriorities.Add(eAACPriority.ToString());
}
return new JsonResult(listPriorities.ToList());
}
else if (strRouteText.StartsWith("order"))
{
List<Order> listOrders = _infAgvSystem.GetOrders();
Order objOrder = listOrders.Find(x => x.WMSID == orderid);
if (objOrder != null)
{
AACPriority eAACPriority;
if (Enum.TryParse<AACPriority>(Convert.ToString(objOrder.Priority), out AACPriority eTryAACPriority))
{
eAACPriority = eTryAACPriority;
}
else
{
eAACPriority = AACPriority.LOWEST;
}
WebDisplayOrder onjWebDisplayOrder = new WebDisplayOrder(objOrder.State, objOrder.Index, objOrder.WMSID, objOrder.Pick, objOrder.Drop, objOrder.AgvID, objOrder.Status, objOrder.Sequence, eAACPriority);
JsonResult objJsonResult = new JsonResult(onjWebDisplayOrder);
return objJsonResult;
}
else
{
return null;
}
}
I have tried many different names and cases, but do not know how to determine the name needed or how to add it if that I needed.