Translating this server side script to .net
Translating this server side script to .net

Hi all, I had a sudden need to implement a draggable row order and this example is perfect. I'm having a bit of a time converting the server side script to .net though, does anyone know if it has been done before? Specifically the .on events, I usually put my listeners in jquery so I'm not sure how that translates as I'm not a php person.
Below is my garden-variety server-side controller method I've been using:
public ActionResult Method()
{
var dbType = Globals.dbType;
var dbConnection = Globals.dbConnection;
using (var db = new Database(dbType, dbConnection))
{
var response = new Editor(db, "table_name", "id")
.Model<DataModel>()
.TryCatch(false)
.Process(Request)
.Data();
return Json(response);
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
The .NET download package includes that example. This is is for .NET Core (which it looks like you are using):
Allan
Oh awesome thanks Allan I forgot about the example solution you can download!
@allan - Allan is there an easy way to sort the json in the controller based on the new sorting? ie. if you do a get on the same api endpoint the datatable uses, I want to sort the data object in the same order that the new order is defined as.
I'm afraid not since the ordering (sort) is applied by DataTables on the client-side. So it doesn't really matter what order it is read from the database (and thus what order it is in the JSON). Therefore Editor doesn't present an API for that.
If you need the data to be ordered in the JSON (although I'm not sure why that is required?) you'd have to use a VIEW in SQL and tell Editor to read from that, rather than the table.
Allan