Multi-column Headers With Kendo Grid

不羁的心 提交于 2019-12-07 05:28:22

问题


I don't know what this is called, and I've messed around a lot with the headerTemplate but can't figure out how to produce this look. I need the second row of column names to 'act normally' in terms of sorting and filtering, but everything I try breaks that. I have no idea if headerTemplate is even the right way to do this? Is there a name for this kind of grouping? My research is turning up a whole lot of nothing, so I suspect I'm using the wrong keywords. What is this layout called?

Note: for security reasons I can't post a code dump (super nervous about the image too). If a specific thing is needed, please let me know and I'll try to anonymize it. But, mostly I'm just looking for suggestions to try other than playing with the headerTemplate.


回答1:


You won't be able to achieve multirow Group headers via Kendo grid on MVC, although there were discussion to add the feature in the current version(2014Q2) of Kendo. See below link for more reference:
Pivot Grid StackOverflow Reference

However, you can achieve the multirow header option via jquery on databound event of the grid. But it is a workaround rather than a perfect soultion.
Please see the js function for databound event to add multirow header:

 function onDataBound(arg) {
     var myElem = document.getElementById('trParentHeader'); //Check if Parent Header Group exist
     if (myElem == null){ // if parent Header doesnot exist then add the Parent Header
        $("#grid").find("th.k-header").parent().before("<tr id='trParentHeader'>  <th colspan='2' class='k-header'><strong>Products + Unit Price</strong></th>  <th scope='col' class='k-header'><strong>Single Units in Stock</strong></th></tr>");
     }
  }

For more understanding and a working example please see below Sample:

MultiRow-Column Header Sample

Please let me know if you if you have any queries.




回答2:


This is now natively supported by the Kendo grid. Here's an example.



来源:https://stackoverflow.com/questions/24812800/multi-column-headers-with-kendo-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!