Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I have Detail View display different content based on which column clicked? #272

Open
startovernow opened this issue Sep 21, 2017 · 2 comments

Comments

@startovernow
Copy link

startovernow commented Sep 21, 2017

Hello All,

I would like to have a table with two different "View detail" (for example, "View detail 1" & "View detail 2") column, depends on which column's cell is clicked, I will make corresponding ajax call to get related data and display them in detail view.

I wish that I could pass in another parameter to "detailFormatter" telling me which column's cell is clicked, then problem solved!

Or, can I have two different "detailFormatter" function, one for each "View Detail" column?

Any suggestions? Thanks very much!

@ggywebtech
Copy link

Hi,
I'm guessing you're talking about clicking in a cell not the column or row, as per the current detail view which is clicking the row.
In the docs http://bootstrap-table.wenzhixin.net.cn/documentation/#events
you could try onClickCell. $('#table').on('click-cell.bs.table', function(field, row, value, element)
Then use expandRow detailed in the Doc "methods" with detailFormatter as normal.
Maybe the only thing that looks a bit odd, would be the details view "+" will be in the first column.
Although it could be possible to hide that column.
Sorry no time for a jsfiddle on this one.
Regards

@startovernow
Copy link
Author

@ggywebtech , you are correct. I am expanding detail view when "View Detail" cell is clicked, my "+" column is hidden.
The solution I came up with is using a global var to track which column the cell belongs to when it is clicked, in $tbl.on("click-cell.bs.table", function(e, field, value, row, $element) {...}
Then in detailFormatter, based on that global variable, making corresponding ajax call.
It may not be the best solution, but works for now.
Thanks for your response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants