KoolReport's Forum

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

Static cloumns, Icons, tags and Buttons (in cloumns) in a table #2200

Open Komuraiah A opened this topic on on Jul 12, 2021 - 16 comments

Komuraiah A commented on Jul 12, 2021

Dear Team, Currently I am working on a report in that I need to customize the table columns.

  1. Need to add a static column.
  2. Need to add some icons instead of data in the table column.
  3. Need to add the colour to the text based on another column value.

https://www.koolreport.com/examples/reports/datagrid/complex_headers/

I have implemented the concept of complex harder also but we are not getting the desired output.

please help me to implement the above things.

Sebastian Morales commented on Jul 13, 2021

Regarding your points:

1 . Fixed (static) columns: pls try datagrid/DataTables with FixedColumns plugin like this:

DataTables::create([
    ...
    "plugins" => [ "FixedColumns" ], // add other plugins if you use them
    "options" => [
        "fixedColumns" => [
            "leftColumns" => 2, // fix the two first columns from the left side
            "rightColumns" => 1, // fix the one first column from the right side
        ]
    ]
]);

2 . What is the type of your icon? If it's an image, use a <img> tag with "src" linked to your image path and put the <img> as data for your column. If its a font image (like font-awesome, etc) use the icon html string as data for your column.

3 . You can use either Table's or DataTables' "cssClass" property to set css class for your cell base on its value and other columns' values:

https://www.koolreport.com/docs/datagrid/datatables/#set-custom-css-classes

DataTables::create(array(
    ...
    'cssClass'=>array(
        'table' => ...
        'th' => ...
        'tr' => ...
        'td' => function($row, $colName) {
            // this column's value = $row[$colName]
            // $row also contains all other columns' values
            // return the css class you want based on $row and $colName
            $cssClasses = ...
            return $cssClasses; 
        },

Then add css color rule for the td css class you set.

Komuraiah A commented on Jul 13, 2021

Dear Team, Thanks for the valuable information.

  1. I would like to implement the concept of the static column. What I mean is I need a column in which I need to pass the static column name and data. I can't pass the column name from a query.

  2. I have 9 columns named col 1, col 2, col 3, col 4, etc. Now, these 9 columns need to get under one column name Main header. I have implemented the concept of Table header under the table section and complex header under the data grid section but no use.

So cloud you please help me.

Komuraiah A commented on Jul 13, 2021

Dear Team, Please help me with the below-mentioned points.

  1. I would like to implement the concept of the static column. What I mean is I need a column in which I need to pass the static column name and data. I can't pass the column name from a query.

  2. I have 9 columns named col 1, col 2, col 3, col 4, etc. Now, these 9 columns need to get under one column name Main header. I have implemented the concept of Table header under the table section and complex header under the data grid section but no use.

So cloud you please help me.

Komuraiah A commented on Jul 13, 2021

Dear Team, Please help me with the below-mentioned points.

  1. I would like to implement the concept of the static column. What I mean is I need a column in which I need to pass the static column name and data. I can't pass the column name from a query.

  2. I have 9 columns named col 1, col 2, col 3, col 4, etc. Now, these 9 columns need to get under one column name Main header. I have implemented the concept of Table header under the table section and complex header under the data grid section but no use.

3.How to use multiple format values for a single column in data table.

So cloud you please help me.

Sebastian Morales commented on Jul 14, 2021

I can not understand what meant. Pls give us some specific examples, with mock up images if it's possible. Tks,

Komuraiah A commented on Jul 15, 2021

Dear Team, I am attaching a sample output of my requirement to the comment please have a look at it.

2 columns one with static data and the 2nd column contains 9 icons or 9 columns under a single header.

Komuraiah A commented on Jul 16, 2021

Dear Team, Please cloud you provide me with the solution for the query. 2 columns 1. one with static data. 2. The 2nd column contains 9 icons or 9 columns under a single header.

Sebastian Morales commented on Jul 16, 2021

For the static column, you could use the fixed column solution for the first column in my previous post:

Fixed columns

For the rest of columns you could use the Map process in report setup to concatenate them together under only one column:

    ->pipe(new \koolreport\processes\Map(array(
        "{value}" => function($row) {
            $row["combinedColumn"] = $row["col2"] . $row["col3"] ... . $row["col10"]; // concat these columns however you want, with separator in between if you want
            return $row;
        }
    )))                

Then in your report view. just show the static column and the "combinedColumn". Rgds,

Komuraiah A commented on Jul 17, 2021

Dear Team, I am not asking solution for the fixed column. My requirement is a static column with my own data I will not retrieve the data from the query or table. I would like to pass on my own data.

  1. Is it possible to use multiple format values for one column. I have a column named "count" in that count column my requirement is

1.1 "I need to represent the count in colour i.e, if the count is >0 green or else red"

1.2 "For the same column named count, I need to provide a hyperlink also".

Komuraiah A commented on Jul 17, 2021

Dear Team, I am not asking solution for the fixed column. My requirement is a static column with my own data I will not retrieve the data from the query or table. I would like to pass on my own data.

  1. Is it possible to use multiple format values for one column. I have a column named "count" in that count column my requirement is

1.1 "I need to represent the count in colour i.e, if the count is >0 green or else red"

1.2 "For the same column named count, I need to provide a hyperlink also".

Komuraiah A commented on Jul 17, 2021

Dear Team, I am not asking solution for the fixed column. My requirement is a static column with my own data I will not retrieve the data from the query or table. I would like to pass on my own data.

  1. Is it possible to use multiple format values for one column. I have a column named "count" in that count column my requirement is

1.1 "I need to represent the count in colour i.e, if the count is >0 green or else red"

1.2 "For the same column named count, I need to provide a hyperlink also".

Sebastian Morales commented on Jul 21, 2021

To add color to your "count" column please use the "cssClass" property:

https://www.koolreport.com/docs/koolphp/table/#table-settings-cssclass-options

Decide css classes based on $row value for column names. Then add color css rule for those css classes. Rgds,

Komuraiah A commented on Jul 26, 2021

Dear Team, Please help me with the solutions to my requirement.

  1. A "Static Coloumn" with my own specified data. I mean I will pass my own data not from the database. (not any fixed column).

  2. Multiple "formatValues" for a single column.

  3. How to populate the data in HTML tag/format instead of table/data tables. For the data which is fetched from the stored procedure.

Komuraiah A commented on Jul 26, 2021

Dear Team, Please help me with the solutions to my requirement.

  1. A "Static Column" with my own specified data. I mean I will pass my own data, not from the database. (not any fixed column).

  2. Multiple "format values" for a single column.

  3. How to populate the data in HTML tag/format instead of table/data tables. For the data which is fetched from the stored procedure.

Komuraiah A commented on Jul 26, 2021

Dear Team, Please help me with the solutions to my requirement.

  1. A "Static Column" with my own specified data. I mean I will pass my own data, not from the database. (not any fixed column).

  2. Multiple "format values" for a single column.

  3. How to populate the data in HTML tag/format instead of table/data tables. For the data which is fetched from the stored procedure.

Sebastian Morales commented on Jul 27, 2021

Pls solve one by one problem. With each problem, describe it specifically with code, screenshots, mock up if possible. Rgds,

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
help needed

None