Editor with Joins

Editor with Joins

arnorbldarnorbld Posts: 110Questions: 20Answers: 1

Hi guys,

I'm working with a user table. I'm creating a related table, userConfig where I need to add ONE row for each user as they need to. The userConfig table does NOT have a record for each user to start with. I.e. when I start with this, the user table might have 100 rows, the userConfig will have 0. This is a 1:1 relationship, one userConfig row per user.

So I need the HTML table browse the user table and then I need to be able to call a form to insert/update data in the userConfig table.

I know the editor supports joins, but since I'm not editing anything in the user (parent) table, only in the userConfig (1:1 child) table, I'm not sure exactly if that can be done and how. It would need to know to insert a new record into userConfig if it doesn't exist.

Any suggestions would be most welcome :)

Arnor

Replies

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    So your DataTable is based on the user table? But you want all editing in this case to happen on the userConfig table?

    If they both have the same primary key column name and value (i.e. use that for the join, so userConfig doesn't have an auto increment) then I think what you are looking for could be done with the readTable method in our server-side libraries.

    You can see that in action here where it is being used to read values from a VIEW, but write to a table. In your case you would read from user and write to userConfig. To be honest, I haven't tried that, but that's what I would try in the first instance. The benefit of this method is you can use all the Editor validators and stuff.

    However, it wasn't really designed with that in mind, so while I think it might work, I might have forgotten something... If that is the case, then I think you would need to use server-side events - so on preEdit you could do an upsert using our push method...

    Sorry I don't have a straightforward answer for you - but please let me know how you get on with this one.

    Regards,
    Allan

This discussion has been closed.