KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Support for adding id to table #344

Open michael opened this topic on on Jul 2, 2018 - 10 comments

michael commented on Jul 2, 2018

is there or will there be any support for adding ID to table? after a table is rendered, i'd like to be able to address it with other custom code, but see no way to assign an ID so I can easily address it.

michael commented on Jul 2, 2018

nevermind.

"name"=>"foobar" in the table options.

michael commented on Jul 18, 2018

fwiw, this doesn't seem to work in the 'datatable', but the other 'table'. (at least not when used in 'widget/instant' approach.

KoolReport commented on Jul 19, 2018

Hi Michael,

I was reading your case but have not fully understood your need. Could you please add a little code so that I could follow you.

michael commented on Jul 19, 2018
Widget::create(DataTables::class, array(
    "dataSource"=>(
        $dataSource->query($sql)
    ),
    "options"=>[
        "id"=>"foobar",
    ]
));

being able to reference the table by $("#foobar") for some other processing later. This seemed to work in some cases, but isn't working in the case of this being used in a 'widget' context.

KoolReport commented on Jul 20, 2018

Oh I see, for all kinds of widget, you can set the name for it, for example:

DataTables::create(array(
    "name"=>"my_table",
    ...
))

or if you use with Instant;

Widget::create(DataTables::class,array(
    "name"=>"my_table",
    ...
))
michael commented on Jul 20, 2018

i will check again - 'name' was another I tried, but didn't seem to be working.

You may want to consider adding that to the doc page for the table components.

Eugene commented on Jun 5, 2020

Hi, I am sorry that I return to this question, but there is no answer. How to set the "id" for the koolreport table?

Now We can have something like this

But what if I need to have a specific id for <table>? Sure I can try to do something via JS and set id, but maybe there is a more simple and transparent way?

ankit raj commented on Jun 5, 2020

Yes , it would really make it convenient instead of going through the js way. plus its a bit confusing when multiple tables are there and you wanna access individual datatable event handling

David Winterburn commented on Jun 8, 2020

Hi,

I think there're two solutions for this case:

  1. Modify the template file Table.tpl.php and add id="<?php echo $this->name; ?>_table" to the table tag.

  2. Refer to the table with this selector:

#mytable > table
Eugene commented on Jun 8, 2020

sure it will work in some cases

But my question was caused by the fact that a certain 3d party package required to specify the id of the table, so the option of accessing by the selector did not work in my case - it was not under my control/

Changing the template means keeping this in mind during updates, and I would not say that this is a universal method.

Nevertheless, as a recommendation and suggestion, I would like to see the opportunity to specify a name, id, class for any HTML element generated by koolreport - tables, charts, controls wrappers etc. I am sure it is not difficult but will add some flexibility to koolreport.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None