added optional withHeaderCaptions method to Tables#305
added optional withHeaderCaptions method to Tables#305jnbn wants to merge 2 commits intopatricktalmadge:masterfrom jnbn:master
Conversation
for specifying different colum names. (table headers)
|
I see you closed this - for future people that see this implementing the TableInterface is probably a better bet instead of converting your model to an array. |
|
Oh I didn't realize there was an interface sorry. By the way, I saw that items are rendered according to the $headers in renderItem method so i cancelled the request. Do you have any suggestions for implementation instead of modifying renderItem method? |
|
I don't think this is a feature that's needed to be honest. If you need to a different caption for a column then you should convert that before you send it to the Table object. In this case since you're already using a model it's much simpler to have your model implement the TableInterface so you get the headers you want. |
|
Actually - this is just changing the caption for the header right? Then |
|
Yeah but renderItems uses $value = $this->getValueForItem($item, $heading); and if you change the keys on header you can not display the items on the table properly |
|
Yes - but all your changing is the header caption. You should just need to edit renderHeaders and possibly getHeaders |
|
changed the methodname to withHeaderCaptions and modified renderHeaders |
for specifying different colum names. (table headers)
When you're using with pre defined arrays from controllers, they usually include database colum names which needs to be displayed properly and this method overrides the titles.
Let's say you have id,name,is_approved and timestamps on your companies object which you get from your ORM and converted to an array as expected to work with Tables.
like
Normally it should display those keys but now you can use it like to override certain fields.
Other fields like id and name would be displayed as themselves.