Get and Edit data for individual users

Get and Edit data for individual users

vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
edited January 2013 in Editor
I am using latest version of data-table editor.
In my project, each authenticated user should see the relevant data in the table for him.
Also the editing privileges are given accordingly.
I would like to know best method that can be used for these functions. I am thinking to incorporate this check in 'REST interface'(as in example) to verify the user and privileges . Or shall I use 'DOM sourced table' (as in example)( to get only the relevant data for given user). please advice me.

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    From your two options, I'd say the REST interface option would be the best way. Then the server will only return the data that can be seen by that particular user.

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    Thank you Allan,
    Using REST interface I get the initial table data using the code
    [code]"sAjaxSource": "php/rest/get.php"[/code]
    But how to restrict the data to be fetched for that particular user ?
    suppose, For a particular user need to display only the data related to 'Internet Explorer' as browser.
    What is the extra code i have to add for that in the editor example ?

    [code]
    include( "browsers.php" );
    $editor
    ->process($_POST)
    ->json();
    [/code]
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    > But how to restrict the data to be fetched for that particular user ?

    Use the `where` method to add a WHERE condition to the SQL: http://editor.datatables.net/docs/current/php/class-DataTables.Editor.html#_where

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    edited January 2013
    Thank you Allan,
    Very quick reply and it works well for me. But please see the REST interface example the DELETE not working well. Even though it removes the data from database it does not get deleted from table (remove.php could not complete, fail to refresh table itself) .
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    > But please see the REST interface example the DELETE not working well

    Appears to be working okay for me. This example here: http://editor.datatables.net/release/DataTables/extras/Editor/examples/REST.html ?

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    yes Allan ,
    in that example, on pressing delete button action does not complete, even though it deletes the data from the database. The dialog window does not closes or refreshes the dom table.
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    As I say, it appears to be working no problem for me. What browser are you using? Do you get an error in the console?

    Allan
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    it seems IE, fire fox and chrome displays the same way. Not closing the window "Are you sure you wish to delete 1 row?" and waiting for response.
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    Do you get an error in the console?

    I've tried, Safari, Firefox, IE and Chrome and all work no problem for me.
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    sorry for the trouble Allan, It may be my antivirus AVAST and its web shield making the difference, I will check it with another system.
    by the way I have one more doubt in the REST interface method. To load the table I am calling [code]"sAjaxSource": "php/rest/get.php"[/code]
    and in this php file I am using[code] ->where( '$ table column name', '$ user given data' )[/code]
    How to pass these parameters along with this ajax request
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    http://datatables.net/release-datatables/examples/server_side/custom_vars.html
  • vinod_ccvvinod_ccv Posts: 75Questions: 0Answers: 0
    wow, that works fine
    [code]
    "fnServerParams": function ( aoData ) {
    aoData.push( { "name": "more_data", "value": "my_value" } );
    }
    [/code]
    I am able to process this values in the ajax source file and retrieve the data accordingly from database using WHERE condition. Thank you Allan.
This discussion has been closed.