Full Editor For Multiple Child Rows
Full Editor For Multiple Child Rows
I have 3 tables:
Host (the parent) - HostKey, Hostname, IP, Location
Drives (child of Hosts) - Drivekey, HostKey, Model, SerialNo, InServiceDate
Functions (child of hosts) - FunctionsKey, HostKey, Function
Both Drives and Functions contain many records per HostKey.
I was looking for an example of how to enable editing (I have the Editor plug-in) for both the parent and child records. I know I listed two child tables above, but an example of a single pair of parent-child editing would suffice.
I have seen child editing, but not using a table for the edits, only a single pop-up with the host record and select boxes. I'm in need of full edit capabilities of every child record.
Ideally it would allow inline editing of the parent, an expand button for the child which would expand like the Sliding Child examples except it would show a full table of all the child records with full edit capabilities. A pop-up for the child editing is ok too.
As I said, I have looked around for a starting point but I can find none. I would have thought this to be a common scenario with one-to-many editing.
Any help or pointers would be appreciated.
Thanks,
Frank
This question has accepted answers - jump to:
Answers
don't know if its what you're after, but here goes...
still new to editor, but slowly getting the hang of it
i have a page with 2 datatables in a parent and child relationship, for orders and order details.
selecting an order in the top table reloads the data in the bottom order details table.
both tables are editable, (though in the linked example, not many fields are)
clicking the link in the details table, and checking the box in the editor, will set a date field
take a look and if it helps, i can post some code
http://test2.forthwebsolutions.com/plugins/shop/orders.php
Thanks for the link.
This is sort of what I was looking for but I need to directly edit the order details (CRUD).
I'm thinking maybe I'll have to put a hyperlink in on of the parent table's columns that will child pass session variables or POST data to a new page dedicated to editing the child details for the parent record.
Frank
You can do that, but my example has been locked down a bit.
I will change the editor instances and update it
try http://test2.forthwebsolutions.com/plugins/shop/ordersdemo.php
there are more editable fields for both the orders and order details
@franks59 - If the relationship between the tables is one-to-one for the records, then you can use Editor's
leftJoin
method to do what you need (assuming you are using the provided PHP or .NET libraries?).Consider this example. The second table is updated in the location field. It just so happens in this case that an
select
input makes best sense here, but you could also use a text input or any other type.Equally, the editing can be updated n layers deep if you need multiple across multiple tables. On the client-side it is "just a field" while on the server-side the libraries should take care of everything for you once you have the left join set up.
Worth reading the left join documentation which explains this in more detail - PHP - .NET.
Allan
The relationship is one-to-many as in each computer host will have multiple drives installed., or as in Crush 123's example - each Order has many Line Items.
I have followed and understand the join plus I have verified that the join I created returns multiple child records for the host.
The problem is how to display the multiple child records in an editable table. The examples I saw (and reproduced myself) only display a single parent record with the child records either concatenated into a single field or set up as a series of checkboxes.
What I'd like is to be able to edit the parent record as a table, then expand the parent record and see an editable table of all the child records associated with the parent.
Thanks,
Frank
I see, so the child record doesn't get edited at the same time as the parent table? If so then what I would suggest is having two different Editor instances on the page - one for the parent table and one for the children. In the child row details have an edit button that will cause the child Editor to activate. It would probably need to operate as a standalone Editor, unless you were to create the child rows as an inner DataTable (which would be done by initialising a new DataTable once the child row has been populated with a plain HTML table).
Allan
Thanks Allan,
Any examples of the inner Data Table and how to populate it with the data returned by the join operation?
Frank
Not really I'm afraid - I really need to get around to making one!
Basically what you could do is to is create a simple HTML table when you call the
row().child()
method. Then immediately after initialise a DataTable on that newly created table - that could Ajax load the data to show so it would be exactly like any other DataTable.For example:
Allan
@Crush123,
Are you using the Editor PHP classes to retrieve the order details? If so, do you have a snippet you can share? I can't figure out how to use the Editor classes to retrieve a specific set of records. I have the detail key in the request object as per your js example, but I don't see how to tell the Editor PHP class to restrict it's query to only that key.
@Alan,
Is there an example of using the Editor PHP class to retrieve specific records such as "where id=123" and how to pass that key from the Editor JS?
Thanks,
Frank
Sure,
I have a single php page with 2 instances of editor, each with their own ajax source
php script
each editor/datatable instance has a separate ajax source
orders
order details
Hope that will help you out
@Crush123
Thanks,
The "where" function is what I was looking for!
In your details php file, I kept getting an error on updating the child table, so instead of the logic you had in the orderdetails php file, I decided to instantiate one of two versions of the Editor class. If $GET was set, I created an instance with where(), if not, then I din't include it. Works great.
In any case, this really helped a lot!
Thanks,
Frank
Cool,
@Alan
For me, the next step would be to incorporate the order details as child rows, so that the order would be the main row, and the child row details would be visible on click.
Don't know if this is possible, but if it is, some pointers or a tutorial would be awesome.
@fsmith - Documentation for the
where()
method is in the PHP reference documentation. Click the row to get more details.@crush123 - Sounds basically like what I was trying to describe above. You would create a DataTable in the child row and then just apply Editor as normal.
Might be a little while before I can create a demo of that, but tis a good idea for one!
Allan