Is it possible to apply css or bootstrap buttons to an unknown column using jquery functions?

Is it possible to apply css or bootstrap buttons to an unknown column using jquery functions?

vaishnavkokavaishnavkoka Posts: 132Questions: 23Answers: 1

I have seen this example code, i would like to know is there any way to target unknown column (ex: "salary" which is hidden column) and apply styling based on yes or no value here is my sample

Thanks
Koka

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @vaishnavkoka ,

    Yep, this example here shows a tooltip being created with a hidden column. The data for that row will be available.

    Cheers,

    Colin

  • vaishnavkokavaishnavkoka Posts: 132Questions: 23Answers: 1

    hey @colin ,

    I hope you have gone through my "sample" link, here is the screenshot i have attached, I would like to change the value to green(using css) if the "YES" is detected in my datatable row else it would red( if "NO" is detected), here the column is unknown to me , i have made an rectangle whose values need to be colored.
    http://prntscr.com/lc2yym

    Thanks
    Koka

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    In your format() function to display the child detail rows you would add logic to set the CSS appropriately based on the value of the data. If you need help with this please post a test case with an example of your data and your code. Without a test case with your specific data and code it would be difficult to provide a complete answer.

    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • vaishnavkokavaishnavkoka Posts: 132Questions: 23Answers: 1

    Hi @kthorngren ,
    I wish i could give you a test case, but I the url i have for ajax purpose doesnt work now, anyway here is the sample

    I would like to apply a css on "salary", which is an uknown column, Is there any way to achieve it ?
    I thought of achieving this task with the help for "columnDef and render function, but target is unknown to me.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    The test case doesn't have to use your ajax data source. It just needs an example of your data that can be applied to Datatables using the data option.

    Using the example you linked to I created this example that uses applies red to any salary that is less than $100,000 (length of salary string is less than 8). Otherwise it applies blue.
    http://live.datatables.net/huqireka/1/edit

    Ashton Cox has a salary of $86,000 so it will be red. All others on the first page are above $100,000 so will be blue.

    HTH,
    Kevin

  • vaishnavkokavaishnavkoka Posts: 132Questions: 23Answers: 1

    Thanks @kthorgren,

    This is exactly what i was looking for.

    Regards
    Koka

This discussion has been closed.