Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

ASP.NET MVC InLine Editing of a Grid

Back to Forum: Tech Off
  • User profile image
    RamblingGeek​UK

    I would like a grid with in line editing, this seems really difficult with MVC.... where am I going wrong?

    I've been looking at this, writing the data back seems difficult...  

    http://help.syncfusion.com/aspnetmvc/datamanager/data-binding

    I'm just trying to get my head wrapped around this stuff... hobbyist programmer... 

     

  • User profile image
    figuerres

    Well let me see if I can help a bit...  and by the way the last few months I have been working on a project using Web API and OData 4.

    if you have a page that has data from a row of a table in your database for example.

    you can have an OData 4 Controller that will accept a an update to that row using the HTTP verb Patch or Merge.

    the Action on the server of the OData controller is to get a class that it can map to the database for example using Entity Framework.

    the class that it gets will have the data to be updated and the key for the record.

    so the code will apply the changes and do the update.

    the client side code will have the data in the form of a JSON object that has name value pairs that the OData code will be able to map to the entity to be updated.

     

    that is how OData can do this.

    with WEB API you can make the code more custom and I use WEB api form some cases.

    but the same pattern of passing a JSON object to an HTTP / AJAX call to the server and on the server a controller picks up the data and processes it.

    the nice thing about OData when you get into it is that you do not need to write a lot of different web service methods to work with the data.

    it starts by mapping the HTTP verbs to the database operations and then adds in some options to describe what you want the sql to be like, but  it's all done via the HTTP URL

    So  you have

    HTTP      =====  >    SQL

    GET                         Select

    POST                        Insert

    PATCH                     Update

    DELETE                   DELETE

     

    an ODATA controller will generally have two "GET" methods one that is just a bare GET and the other that will have a parameter that you map to the key of the table to get one record.

    I map the DELETE verb to code that updates a record to mark it as deleted in the system so that a users delete is not an undoable action.

    you can use a Generic base class to map a lot of tables with minimal code if you use a common set of column names in your database, or use entity framework attributes to do the mapping in EF.

    it works really well for us so far, we are about 5 months into a large project.

     

  • User profile image
    spivonious

    @RamblingGeekUK: Definitely check out one of the many client-side javascript MVVM frameworks (e.g. Angular, Bacbbone, Ember). It will do all of the heavy-lifting for you; you'll just need to hook up the UI to your (javascript) data. Then all you need is a server endpoint to send your updated model.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.