Hi, i am using ASP.NET MVC 5.X with JQuery. I want to call a controller method instead of service method when loading data into a jtable. I need to store some data in viewdata or as a session object and populate the jtable from one of those objects instead of pulling data from a database. Whats is the best way to achieve this using abp.
3 Answer(s)
-
0
Hi,
You just need to set your controller action's url to jTable's list action
actions: { listAction: '/Demo/StudentList' }
For more info, you can check jTable samples and docs. <a class="postlink" href="http://www.jtable.org/">http://www.jtable.org/</a>
Thanks.
-
0
I tried doing s before posting but i get a javascript error - Uncaught TypeError: originalListAction.method is not a function.
see code below
Javascript Script Code:
_$bagsTable.jtable({
title: app.localize('Bags'), actions: { listAction: "/Mpa/DepositProcessingToTreasury/GetBagsToBeTransfered" }, fields: { id: { key: true, list: false }, bagNo: { title: app.localize('BagNo'), width: '10%' }, fit: { title: app.localize('Fit'), width: '10%' }, currencyCode: { title: app.localize('Currency'), width: '25%' }, bagTotal: { title: app.localize('Total'), width: '10%' } } });
Controller :
public JsonResult GetBagsToBeTransfered() {
try { List<CashMovementTransactionBagListDto> result = new List<CashMovementTransactionBagListDto>(); if (ViewData["Bags"] != null) { var bagList = ViewData["Bags"] as List<CreateOrUpdateCashMovementBagDto>; foreach (var bag in bagList) result.Add(new CashMovementTransactionBagListDto { BagNo = bag.Bag.BagNo, BagTotal = 0, CashMovementTransactionId = 0, CurrencyCode = "JMD", CurrencyId = 1, Fit = true, Id = 0 }); } return Json(new { Result = "OK", Records = result }); } catch (Exception ex) { return Json(new { Result = "ERROR", Message = ex.Message }); } }
-
0
Hi,
Then, there might be a bug in jTable. Let us check this and get back to you.
Thanks.