企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
## JS 组件封装后方法 ``` vm.dataBoundMethod = function (e) { vm.kendoGrid.resizeGrid(); } ``` 封装所在文件:cpsKendoSPA.js ``` resizeGrid: function () { var dataArea = this.selfElement.find(".k-grid-content"); var bottomArea = this.selfElement.find(".k-grid-pager"); var newHeight = $(document.body).height() - this.selfElement.offset().top; var diff = this.selfElement.innerHeight() - dataArea.innerHeight(); this.selfElement.height(newHeight - bottomArea.innerHeight()); dataArea.height(newHeight - diff - bottomArea.innerHeight()); }, ``` ## JS原始实现方式代码 高度自适应方法 ``` var _resizeGrid = function (_grid) {             var dataArea = _grid.find(".k-grid-content");             var datasArea = _grid.find(".k-grid-content-locked");             var bottomArea = _grid.find(".k-grid-pager");             var newHeight = $(document.body).height() - _grid.offset().top;             var diff = _grid.innerHeight() - dataArea.innerHeight();             var diffs = _grid.innerHeight() - datasArea.innerHeight();             _grid.height(newHeight - bottomArea.innerHeight());             dataArea.height(newHeight - diff - bottomArea.innerHeight());             datasArea.height(newHeight - diffs - bottomArea.innerHeight());         }; ``` 列表绑定数据后,触发事件 ``` vm.locationGridOptions = vm.kendoGrid.init({             id: 'GridVIewID', //Grid 列表控件id             dataBoundMethod: vm.dataBoundMethod, // 数据绑定成功后触发事件 }); vm.dataBoundMethod = function (e) { _resizeGrid($("#GridVIewID")); //GridVIewID 是列表控件id } ``` 或 ``` vm.locationGridOptions = vm.kendoGrid.init({             id: 'GridVIewID', //Grid 列表控件id dataBoundMethod: function (e) {                 _resizeGrid($("#GridVIewID"));             }, }); ```