Hooking into Editor - Tooltips for select menu

Hooking into Editor - Tooltips for select menu

burncharburnchar Posts: 118Questions: 12Answers: 0
edited September 2012 in Editor
http://datatables.net/examples/advanced_init/events_pre_init.html describes how to create tooltips for mouseover of the main table view.

Web pages often have tooltips for each option in select menus. This is what I would like to do.

I am not sure how to hook in and add help text for each item since the select menu / radio buttons are generated.

In my specific case, all columns of the referenced tables are important for the user's selection, so on mouseover of a select option, I want to do an AJAX call to get "select col1, col2... from referenced_table where id = X."

onInitEdit and onInitCreate look promising, "Useful for manipulating the form specifically for the create state." but I haven't been able to find how to actually perform this manipulation.

How do I add AJAX help text to select and radio button forms generated by Editor?

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    > Web pages often have tooltips for each option in select menus. This is what I would like to do.

    I'm not sure I quite understand that. Each item in the select menu (i.e. the ) has a `title` attribute? I'm not sure I've seen that before. Could you link me to an example of what you mean?

    In general, to modify an input, the best way of doing it is to create a field type plug-in for your input control that creates the HTML and adds events in exactly the way you want: http://editor.datatables.net/tutorials/field_types .

    Regards,
    Allan
  • burncharburnchar Posts: 118Questions: 12Answers: 0
    Use of title attributes with option tags was just an idea (I haven't tried it but suspect it would work). The goal is to get help text regarding the contents of a linked table.

    For example, I am editing table PEOPLE which has a foreign key F to table FAVORITE_CAR.

    The user prefers something besides the number in the FK column. What should I display though?
    If I am writing a special editor for every table, I can make a special query to display the most appropriate column. In the case above, I'd display FAVORITE_CAR.CAR_BRAND or whatever.

    That's a simple case though. In my case, I am generating everything on the fly without knowing anything about the linked table, so the only thing I can do is show ALL columns in the row linked to by the FK.
    Similarly, if I were editing a table where all columns were important (not just an obvious one like CAR_BRAND), I'd need to show more than one column regardless of whether I was generating on the fly.

    I can of course send all of FAVORITE_CAR contents, but that is a bad idea if it's a big table. Thus, when the user edits PEOPLE and has to make a choice for FAVORITE_CAR, I want mouse-over help text (or similar) that makes an AJAX call to retrieve all columns of the requested row in FAVORITE_CAR (the row that the foreign key of PEOPLE which is being edited links to).

    I looked at the field types docs and it looks promising. I'll look at that. I wasn't sure of which terminology to use in a search so didn't come up with that through Google. Thanks!
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    edited September 2012
    [quote]
    For example, I am editing table PEOPLE which has a foreign key F to table FAVORITE_CAR.
    The user prefers something besides the number in the FK column. What should I display though?
    [/quote]

    Exactly as you say, you can show the car brand from the joined table, or any other information that would give a better idea of what the selection is than the row's ID (since that will be meaningless to the end user). For example, in my demo here: http://editor.datatables.net/release/DataTables/extras/Editor/examples/join.html - the 'department' select list shows the name in the tags (and if you inspect the element the value of the tags is the primary key value.

    If it gets more complex than that, what I've done in the past is to use a DataTable with the ability to select rows. That way you can show multiple columns of information quite easily, while still providing the basic options of a select list. Other options might be to create a custom like control which shows multiple fields of information.

    Allan
This discussion has been closed.