|
地板
楼主 |
发表于 2015-6-4 11:40:29
|
只看该作者
回大神!
1 参考demo行扩展列(展开全部)的源代码
http://fineui.com/demo/#/demo/grid/grid_rowexpander_expandall.aspx
有一个封装的方法:- Grid1.ExpandRowExpanders();
复制代码
2 查看ExpandRowExpanders的源代码
- public void ExpandRowExpanders()
- {
- _registerScriptRowExpanders = true;
- ExpandAllRowExpanders = true;
- //PageContext.RegisterStartupScript(String.Format("{0}.f_expandAllRows();", ScriptID));
- }
复制代码
3 Ctrl+F 查找JS代码f_expandAllRows() ,在extjs库里找到
- // 展开所有的行扩展列
- f_expandAllRows: function () {
- var expander = this.getPlugin(this.id + '_rowexpander');
- if (expander) {
- var store = this.getStore();
- for (var i = 0, count = store.getCount() ; i < count; i++) {
- var record = store.getAt(i);
- if (!expander.recordsExpanded[record.internalId]) {
- expander.toggleRow(i, record);
- }
- }
- }
- }
复制代码
4. 参照3的代码,使用行号只修改第一行。- <script type="text/javascript">
- var gridClientID = '<%=Grid1.ClientID %>';
- //展开一行
- function expandRow(id, num) {
- if (gridClientID == undefined) return;
- var grid = F(gridClientID);
- var store = grid.getStore();
- var expander = grid.getPlugin(gridClientID + '_rowexpander');
- var record = store.getAt(num);
- expander.toggleRow(num, record);
- }
- //页面第一个加载完毕后执行的函数
- F.ready(function () {
- expandRow(0, 0);
- });
- </script>
复制代码 |
|