Refreshing the data after changing dropdown

Refreshing the data after changing dropdown

pzh20pzh20 Posts: 66Questions: 15Answers: 0
edited February 2015 in Editor

I am using the example code at https://editor.datatables.net/examples/inline-editing/tabControl.html

I want to add a form element outside the table where I select a value that needs to be passed to the query to select the data.

How might I go about it?

Regards
Pete

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    You could use ajax.data as a function to modify the data object Editor sends to the server. If you want to modify the data object DataTables sends (when loading the data) use ajax.data.

    Allan

  • pzh20pzh20 Posts: 66Questions: 15Answers: 0

    OK, thanks for this, I want to initialise the dropdown with data based on the user profile, so they see data related to themselves, not everything. But certain users can select a different set of data so the table will need to be refreshed, after it has been initialised with the first set of data and may have been updated.

    It's how I refresh the data that I am not sure of.

    Pete

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Is this in a select list? If so, look at the update() method for the select field type - it provides the option to update the options available in the list.

    Allan

  • pzh20pzh20 Posts: 66Questions: 15Answers: 0

    Alan,
    It's outside the table. Basically I want to capture staff hours, some managers can work across more than one branch, they can change the branch dropdown and a weekending date dropdown too.

    These values need to be passed to the query initially based on their logon profile or if they change the dropdowns.

    Pete

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Hi Pete,

    To pass additional information to the server on the initial data get request that DataTables makes, use ajax.data as a function. Then when you refresh the data in the table (which you would do using ajax.reload() - assuming you are using ajax to load the data) that function will be re-evaluated and the extra data sent to the server.

    Example here. You might read the additional information using a little jQuery - d.myVar = $('#myInput').val(); for example.

    Regards,
    Allan

  • pzh20pzh20 Posts: 66Questions: 15Answers: 0

    I'm not sure that I can pass the selected data across to a where clause in the PHP.

    Maybe I will have to write my ASP version.

    Pete

  • pzh20pzh20 Posts: 66Questions: 15Answers: 0

    I'm a little confused as to where the data is passed to/from. I'm using the Editor extension and so if I want to pass this extra data is it the same for Editor as it is for Datatables?

    Regards
    Pete

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Answer ✓

    Hi Pete,

    DataTables and Editor each use their own Ajax configuration object. They basically provide the same options (with a few small variances which are noted in the documentation).

    The option to manipulate the data object sent to the server are the ones I linked to in my first post above:

    Allan

This discussion has been closed.