.NET Core Editor Libraries - without database
.NET Core Editor Libraries - without database

Is it possible to use the Editor libraries with a direct database connection? My data source is coming from a Web API call.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Clarification: Is it possible to use the Editor libraries WITHOUT a direct database connection?
Hi @InsanelyOne ,
Yep, see the examples here where Editor is being used standalone.
Cheers,
Colin
colin, I'm afraid didn't explain myself very well. I've got a .NET MVC application and I was hoping to use the Editor .Net Core library in my controller class.
For instance, the online examples show something like this:
var response = new Editor(db, "staff")
.Model<StaffModel>()
.Field(new Field("start_date")
.Validator(Validation.DateFormat(
Format.DATE_ISO_8601,
new ValidationOpts { Message = "Please enter a date in the format yyyy-mm-dd" }
))
.GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
.SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
)
.Process(formData)
.Data();
In my case, my .NET MVC application does not have direct access to the database. My datasource is an ASP.Net Web API. So I get my data using the HttpClient class. From what I can tell, the Editor() class requires a direct db connection. Am I missing something?
The examples Colin linked to show DT being used with no db connection.
The example that is being linked to does not make a single reference to ASP.NET MVC.
This is what I'm talking about: https://editor.datatables.net/manual/net/mvc
I am not talking about a standalone Editor. I want to use the .NET libraries. I'm trying to determine if I can use a non-database datasource for the Editor() class (this is specific to the MVC controller class on the server side).
I don't know how else to explain it.
Hi,
You aren't missing anything and you are correct, the Editor class does indeed use a db connection (an ADO.NET adaptor). It will generate SQL based on the configuration set up for it. I suppose it would be possible to have the database layer work with something other than SQL, but its not something I've really thought about before.
If you want to use Editor with a preexisting API, then you'd need to write your own server-side integration code. The client / server interface is fully documented and I'm happy to answer any questions you have about it.
Allan
Thanks Allan. I had already gone down the client/server interface path but was just curious if there was another way.
This is what I've got so far. I wanted to modify the data going back to the server to include the name of the field that was updated so I added this pre-submit event code:
My postback controller class (bear in mind this code is just proof-of-concept):
My response class is defined like this:
Let me know if you think I've gone off the rails with this.
That looks good to me!
Allan