Editor with .NET: Joined table is not updating

Editor with .NET: Joined table is not updating

jgessingerjgessinger Posts: 38Questions: 6Answers: 0

Hello Allan,

we just bought your editor plugin and using it with .NET. In the controller action we define the Editor object and made a simple example, where we connect to a table with the editor constructor and using a .LeftJoin to add another table. When we try to edit a value in the table (inline or lightbox), we can just update data from the first table but not from the joined table.

We started Intellitrace in Visual Studio and there is no update sql query sent, when we update data from the joined table. Are we missing something here? We used this manual page https://editor.datatables.net/manual/net/joins

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin

    Hi,

    Editing the joined table is something that Editor supports but you need to get the joined table's primary key value and submit it in the form. Getting it is as simple as adding an extra Field into your fields list for that table / column.

    Then in your Javascript for Editor add a new field for that property and make it type: 'hidden' so the end user can't modify it.

    Regards,
    Allan

  • jgessingerjgessinger Posts: 38Questions: 6Answers: 0
    edited June 2016

    Thanks for your help.

    Problem 1:
    I added the primary keys in the model and added it in javascript as hidden fields. This is working as expected and it is posting the additotional ids now. It also tries now to update the joined tables. The main problem is, that the update statement tries to set the posted primary key and I get an error output in the lightbox "Cannot update identity column 'xxColumnIdxx'.". I maybe have to mark it as 'do not write this field'?

    Problem 2:
    I use the inline edit feature. But when I inline edit a field, just the content of this field is posted to the action, but the primary key is missing here. Can you tell me best way to extend this post with the hidden field?

  • allanallan Posts: 63,799Questions: 1Answers: 10,514 Site admin
    Answer ✓

    I maybe have to mark it as 'do not write this field'?

    Yes - add .Set( false ) to that field's definition to stop it from doing that. I'm going to write a guide on this, and that's a good point that this should be included!

    Can you tell me best way to extend this post with the hidden field?

    Use the submit option of the form-options (which is passed in as the second parameter to inline()). With that you can set to be allIfChanged so the full form is submitted.

    Allan

  • jgessingerjgessinger Posts: 38Questions: 6Answers: 0

    This is working great! Thank you very much!

This discussion has been closed.