easyUi学习备忘

时间:2022-05-03 12:57:44

1.获取datagrid的自身相关的属性方式:

  jQuery("#grid").datagrid("options").height

  jQuery("#grid").datagrid("options").url

  即:通过jQuery("#grid").datagrid("options")对象就可以获取想要的属性值。

2.JQuery EasyUI内Combobox的onChange事件

  

<select id="modelState" class="easyui-combobox" data-options="width:100,panelHeight:'auto'" style="float:left;">
<option selected="selected">全部</option>
<option>未启动</option>
<option>执行中</option>
<option>已关闭</option>
<option>已归档</option>
</select>
// 可装载组合框
$("#modelState").combobox({
onChange: function (n,o) {
$("#grid").datagrid("load",{
modelState:n!="全部" ? n :"",
structureId:structureId,
structurePath:modelPath,
structureLevel:structureLevel
});
if($("#js_layout").layout("panel","south").is(":visible")){
$("#js_layout").layout("collapse","south");
$("button.layout-split-btn-v").hide();
$("#framebottom").attr("src","");
}
}
});

3.datagrid 添加title

 resizeColumnsFn: function(flag) {
/*自动截取长度*/
var fields = jQuery("#grid").datagrid('getColumnFields');
for (var i = 0; i < fields.length; i++) {
var columnOption = jQuery("#grid").datagrid('getColumnOption', fields[i]);
var innerFields = $('td[field=' + fields[i] + '] div[class*=' + fields[i] + ']');
if (innerFields && columnOption && columnOption.width) {
innerFields.attr('style', 'overflow: hidden; white-space: nowrap; text-align: left; text-overflow: ellipsis;');
if (flag) {
for (var j = 0; j < innerFields.length; j++) {
var el = $(innerFields[j]);
if($.trim(el.text()).length > 0){ el.attr('title', el.text());}
}
}
}
}
}

easyui 自动添加title