Using 2 Editor forms the second being an extended version

Using 2 Editor forms the second being an extended version

ematavematav Posts: 5Questions: 0Answers: 0
edited March 2013 in Editor
In fact I want use one reduced form for the 'create' part which show only required fields and the complete form (with all fields) for the 'Edit' and 'delete' parts. Does Editor support this kind of thing?

Replies

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Absolutely - there are two ways of doing this. Firstly to use two different Editor instances, each configured differently, then in TableTools you would do something like:

    [code]
    { "sExtends": "editor_create", "editor": editor_create },
    { "sExtends": "editor_edit", "editor": editor },
    { "sExtends": "editor_remove", "editor": editor }
    [/code]

    The other option is to listen for the onCreateInit and onEditInit events and show / hide the required fields.

    Allan
  • ematavematav Posts: 5Questions: 0Answers: 0
    Thanks Allan! I went for the first solution but got a warning message "DataTables warning (table id = 'incident'): Requested unknown parameter 'commentaires' from the data source for row 105"
    before adding a new row. All, the returned json include, seems to be correct nevertheless! the field 'commentaires' is not required and is not in the 'create' form.
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    I'd probably need to see the page to be able to say for sure what is happening, but it sounds like you might want to use sDefaultContent to assign a default for the cell?

    Allan
  • ematavematav Posts: 5Questions: 0Answers: 0
    That's ok . After reading your comment it seems obvious for me now :)
  • ematavematav Posts: 5Questions: 0Answers: 0
    Allan,
    In my incidents management table, when In the Editor, I'm checking for duplicate records in creation stage, If the record represent an incident already closed, I want display the record in the update (edit) form and ask the user if he wants re-open and update it.

    How can use the edit form to display the data?
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    To use the edit form to display the data, you need to use the API. Is this an edit form which is already open? If so, then use the `set` method: http://editor.datatables.net/api/#set . If the edit form is not already open, use the `edit` method: http://editor.datatables.net/api/#edit , passing in the row you want to edit.

    Allan
  • ematavematav Posts: 5Questions: 0Answers: 0
    Allan,
    In fact my problem is a little bit complicated. To test a duplicated record in the creation phase, I make a request to the database. If a record with the same incident number exists and is already closed, I want show this record in the edit form and ask the user if he want to re-open the incident.

    So I think I have to insert the found record in the table and show it in the edit form. What api should I use?
  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    It sounds like you need to go through two phases:

    1. Use fnAddData to add the new data to the table
    2. Use the Editor `edit` method to edit the new row ( http://editor.datatables.net/api/#edit ).

    Allan
This discussion has been closed.