Okay
  Public Ticket #1994237
A couple of questions about wpdatatables
Closed

Comments

  • nickharambee started the conversation

    Hello,

    I am wondering if I can do the following things with wpdatatables:

    1. Target a specific table with custom CSS. I can see that the table IDs on the page don't correspond to the ID of the table in the backend - although there is a data-wpdatatable_id="x" within the html tag for the table - can this be used? Or is there some other method?

    2. Can a column be dynamically filled with the current WP username (or can this appended to the value that is already in the column)?

    Thanks,

    Nick


  •  2,572
    Aleksandar replied

    Hello again Nick.

    Thank you for your purchase, and again sorry for the late response.

    1. If I understood you correctly - you want to add multiple tables on a page, and then target each of them individually using custom CSS, correct? If this is true, then it can be done. Each table added to a page gets an odd number assigned to it, so if you have 4 tables on a page, they will be identified like this:

    table_1_wrapper

    table_3_wrapper

    table_5_wrapper

    table_7_wrapper

    So, if you'd like to hide only the headers of the first table on that page, for example, the code needs to be:

    <style>
    .wpdt-c #table_1_wrapper thead {
    display: none !important;
    }
    </style>
    

    And so on.

    2. Please take a look at Users see and edit only own data. I believe it deals with this closely, although I believe that's not what you're looking for. Each user receives a unique ID, and you can see in the link I provided how to create a table where you can use "userid" column to add those IDs to the table. Then, my advice would be to create a separate table for each user and use that table as a foreign key in the first one.

    In that way, the table will assign the unique ID number to a username.

    Please let me know if there's anything else I can help you with.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • nickharambee replied

    Thanks Aleksander.

    The CSS for hiding the header works fine.

    As for the second question, I am still a little unclear. In my instance, on the front end user editable table I would need the Wordpress user id to be entered dynamically into the user id column. I could hide this column and then, as you say, use another table to pull in the user's first name, as a foreign key. But the crucial thing is to be able to automatically populate a column with the user ID. Is this possible?

    Thanks,

    Nick

  •  2,572
    Aleksandar replied

    Hey Nick.

    If you create a table, like described in the documentation, and create that userid column - it will add the user ID of the user that is adding a new row.

    For instance - you have a table where you enabled "Users see and edit only own data", and I'm one of your users. I can only see my own entries, and when I add a new row, the userid column will populate that new cell under that column with my auto-assigned ID. No need for me to type that in.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables