How to add new rows within recursive function?

How to add new rows within recursive function?

bataakbataak Posts: 10Questions: 1Answers: 0

Hi All,

I'm trying to customize modal window rows (datatables editor with server-side-processing). Here is the screenshot: http://bit.ly/219AfKl

server-side-processing.html:

    editor = new $.fn.dataTable.Editor( {
        ajax: "../php/staff.php",

staff.php:

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'datatables_demo' )
->fields(
    Field::inst( 'first_name' )->validator( 'Validate::notEmpty' ),
    Field::inst( 'last_name' )->validator( 'Validate::notEmpty' ),
    Field::inst( 'position' )->validator( 'Validate::notEmpty' ),
    Field::inst( 'email' ),

May I add some code in staff.php file or Editor.php (I want to understand program structure). Actually I suppose if I can catch my values from ajax and parse it, I pass it into process function then insert my data successfully.

How can I add new rows in same fields recursively?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Answer ✓

    There isn't really a built in way to do that. You can create multiple rows using the create() API method and you could then use the API to populate the Editor fields with the values from your form (i.e. have a layer between Editor and your form in Javascript) - that would work, but I'm not clear from the screenshot if you actually have one master row and then multiple sub rows?

    Allan

  • bataakbataak Posts: 10Questions: 1Answers: 0
    edited March 2016

    Thanks for your quick reply. Yes, it is joined table each row dynamically added is joined first column data. Ok, I'll try the create API.

  • bataakbataak Posts: 10Questions: 1Answers: 0

    Hi Allan,

    I'm trying to use create and multiSet API. But I've a problem with catching the value of input fields within modal box via id in javascript (to pass the value into multiSet).

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    I'm not sure that Editor will work for one master row and multiple child rows being created all at once - even when using the API rather than the GUI. The many join aspect was really only designed to be able to reference a single data point, rather than being able to update multiple.

    Based on your confirmation of what you are looking for, I rather suspect you'll find it a lot easier to just post the data from your form to the server yourself and drop it into the database with a little custom code, rather than trying to force Editor to do that.

    Regards,
    Allan

  • bataakbataak Posts: 10Questions: 1Answers: 0

    I understand that was not very easy. But I decided to use view table for datatable grid and to write code for editor to insert (delete and update) master and joined table simultaneously without check whether the value was inserted in the master table already. (my table structure: http://bit.ly/1TEIZtb I suspect it's suitable for use Mjoin class in that table. Link table: uom, item_uom, item_kit and rfq)

    And how can I catch the value via ajax post within staff.php?

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    With problem with Mjoin is that it applies to a single field only - submitting multiple fields for the same join is not easy and not something I've tested with Editor I'm afraid. As such, I'm not sure if the PHP libraries would actually cope with it. I have a suspicion they might, but I'm not certain.

    And how can I catch the value via ajax post within staff.php?

    I'm not sure I understand i'm afraid - wouldn't you just use $_POST?

    Allan

This discussion has been closed.