1 to many join using input text boxes

1 to many join using input text boxes

randy.johnsonrandy.johnson Posts: 18Questions: 8Answers: 0

I don't have a working example yet, just trying to figure out the best way to handle this scenario before jumping into the code.

I am working on a data table for warehouse bin locations and positions in bin location.

1 bin location can have multiple positions

the positions are added at the same time you add the bin location and would be edited on the same screen.

The closest example I was able to find is this one:

https://editor.datatables.net/examples/advanced/joinArray.html

Instead of Checkboxes for "Access" I would want them to be text boxes for positions

Would it be as simple as taking that example and changing the type to text boxes?

My idea if the above is possible is to use show.bs.modal to inject js that would add a + button and - button that would allow the adding / deleting of the positions in bin location.

Am I on the right path or is there a different example or better way of approaching it?

Thank You,

Randy

Replies

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi Randy,

    Would it be as simple as taking that example and changing the type to text boxes?

    Possibly. The checkboxes work in the example you link to because they hold the value of an external primary key column (in this case the access id). Therefore they can be used very easily in a linked table.

    The problem with input elements is that it is very easy for the user to enter invalid information. For example lets say your bin positions are numeric with five digits - 00000 - 99999 are all valid. What happens if the user enters "hi" or "45", etc. You could do validation, but it is unlikely the full range will be valid and positions might be added and removed (depending on your setup). This is why using a linked table with two primary keys is really great for many joins. See also the join documentation.

    You can still use an input box - use something like Select2 or Selectize to allow text input, but fundamentally I would say you want to allow values to be selected from a specific set of data only.

    Allan

  • randy.johnsonrandy.johnson Posts: 18Questions: 8Answers: 0

    In my situation any value in position would be valid because they are not lookup values.

    This particular form is the setup form for a new customer coming on board with the software.

    There would be no preset bin locations and positions. They are being added via this form.

    I took the example and changed the checkbox to an input and it puts all positions in 1 text box comma delimited on an edit.

    Like So:

    http://screencast.com/t/ohmRunZe

    When I do an add it is just 1 checkbox.

    Here is what I am ultimately hoping to end up with:

    http://screencast.com/t/sQ6G9Co43Xp

    Disregarding the plus and minuses is it possible to get the edit form to pop up and look like the mock up above and save correctly or am I going to need to do some customization?

    Thank You,

    Randy

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin

    Hi Randy,

    Without question, for the scone screenshot you would need customisation. However, it might not be too bad, particularly if you are happy to receive a comma delimited string at the server, or even just an array that you can then process.

    The customisation you would need to do is to create a custom field type plug-in that adds the behaviour you are looking for.

    Regards,
    Allan

This discussion has been closed.