Create temporary example entries that clear

Create temporary example entries that clear

bfarkasbfarkas Posts: 181Questions: 48Answers: 0

I was hoping to create 3-5 example entries in a table to help the user figure out what they should be doing. I want this data to clear when the user adds their first actual bit of data. Any thoughts on how to approach? I am using JavaScript all front end.

This question has an accepted answers - jump to answer


  • rf1234rf1234 Posts: 1,866Questions: 55Answers: 280
    Answer ✓

    When you create a new user you could insert example records into the respective database table. When the new user opens the respective page with the data table she sees the example records.
    Then use an Editor event to delete the example data (assuming you use Editor) as soon as the new user creates her first entry.

    The event to use is this one:

    Just do an ajax call to delete the dummy records and maybe do an ajax reload of the data table.

  • allanallan Posts: 55,045Questions: 1Answers: 8,638 Site admin

    That's what I would do as well.

    I guess the alternative is to get the client-side to do it using the create() method. But prepopulating the database would be better I'd say.


  • bfarkasbfarkas Posts: 181Questions: 48Answers: 0

    My plan was to prepopulate with the dom or an Ajax file on load, bigger part of the question is how to identify those entries and delete them upon the first new entry in the session so that when a user goes to put a real entry they are eliminated.

  • rf1234rf1234 Posts: 1,866Questions: 55Answers: 280
    edited February 2020

    For that reason I would do it in the database. There it is very easy to mark them as generated or whatever you want to call it. Use a boolean field "is_generated" or "is_dummy" or whatever. Subsequently do the delete of all "is_generated" records for the user on "postCreate".

    But of course you can do it by other means as well using a hidden field to make sure the user can't see it and which you can check with Javascript in order to know which rows to delete on "postCreate".

    I didn't find much in my code about the latter but here is somehting. I need the id of a record when the user clicks on a link but I don't want to show it to the user. Hence I hide the id using Bootstraps's "hidden" class but you can do that with CSS as well.

    return ( '<a href="" class="linkedContractLink">\n\
                   <i class="glyphicon glyphicon-link" aria-hidden="true"></i>&nbsp;'
                  + row.string + '<span class="hidden linkedContractId">'
                  + + '</span></a>' );      
  • bfarkasbfarkas Posts: 181Questions: 48Answers: 0

    Yeah, I was thinking about the hidden field approach. As I said this is going to be all front end, no database, so I can’t use that as an option.

  • rf1234rf1234 Posts: 1,866Questions: 55Answers: 280
    edited February 2020

    Just thought about an even better option:
    You can create "regular" data tables columns and hide them completely. Afterwards you can still check their values using the api.

    Just add class "never" in your HTML for the respective column. Then the user will never see the column and it cannot be made visible by "colvis" either.

    In some cases I use the same data table on multiple pages using different sets of fields. For that this feature is really useful, too.

    Take a look at this please and search for "Special classes":

Sign In or Register to comment.