Can Editor be used with non sql data ?
Can Editor be used with non sql data ?
In all examples i have seen, editor oprates only on data and models fetched from SQL tables....is it possible to create a custom object and join it with the table data in Editor ?
For example i have a table Users with columns Name, Location, Gender
However i want to expand this model by a new property that dosen't exist in database. For example "Salary" which is calculated inside the controler.
Is there a way to pass such object in to Editor Controller (.net mvc). Or only objects that match db tables can be used ?
This question has an accepted answers - jump to answer
Answers
I think i understand your request.
What I do is to create a datatable.
Then I will call my routine to read the data I want from the database.
I will then fill the datatable via the row.add() call.
When I do this, I can the data from the recordset (converted to json), and optionally add new columns. So below, I have 2 columns from the database and another 2 created as input fields (one checkbox and another hidden field).
Hope this helps.
Hi @plareszka ,
It sounds like this example here may do the trick for you. Here, the date field doesn't exist in the database, but is displayed in the table.
Cheers,
Colin
@colin Not sure if that is right....
But from what i checked in the provided demo sql....table users actually have updated_date column....
My question is...is it possible to add to the Editor/Datatables table, data outside of the SQL table....For the example you used here
What if i i wanted to add column "Second Name" and populate it within the controller with "Robert" for each row ?
Yes you can do that if you want. In the controller you would typically have something like:
You can loop over the
response.data
property and modify its contents as you need. Its an array and each array entry represents a row as read from the DB. That way you can get the extra information for each row using whatever methods you need in the controller.The other option, depending on what you want to do exactly, is that you could use
columns.render
on the client-side. For example if you are performing a calculation, its handy to get the client-side to do it rather than the server.Allan