jQuery EasyUI is a collection of UI plug-ins based on jQuery, and the goal of jQuery EasyUI is to help web developers more easily create feature-rich and beautiful UI interfaces. Developers do not need to write complex javascript, nor do they need to have an in-depth understanding of css styles. All developers need to know are some simple html tags. This article mainly introduces relevant information on the summary of jQuery EasyUI development skills. I hope that through this article, everyone can master the development skills of EasyUI. Friends who need it can refer to it. I hope it can help everyone.
jQuery EasyUI development skills summary
1. When using tabs, if you use content instead of url, you must embed iframe
addTab({ title:node.text, closeable:true, content:‘<iframe src="'+url+'" frameborder="0" style="border:0;width:100%;height:99%"></iframe> });
1) Externally call the tag content in the iframe
<button onclick="console.info($('iframe').contents().find('#frameId'));"/>
2) Internally call the external method :
onclick="parent.getData();"
2. Query submission form:
function serarchFun(){//搜索 $("#datagrid").datagrid("load", serializeObject($("#searchForm"))); } function cleanFun(){//清空 $("#searchForm input").val(''); $("#datagrid").datagrid("load", {}); } function removeFun(){//删除 var rows=$("#datagrid").datagrid("getChecked"); var ids[] = new Array(); if(rows.length>0){ for(var i=0;i<rows.length;i++){ ids.push(row[i].id); } $.ajax({ url:'${rootPath}/user_delete.action', data:{ids:ids.join(',')}, dataType:'json', success:function(data){ $('#datagrid').datagrid('load'); $('#datagrid').datagrid('unselectAll'); $.messager.Show({ title:'提示', msg:data.msg }); } }) }else{ $.messager.Show({ title:'提示', msg:'不能删除' }); } }
3. Add checkbox:
$("#datagrid").datagrid( url:"${rootPath}/user_add.action", idField:'id', checkOnSelect:false, selectOnCheck:true,//选中复选框选中 frozonColumns:[[{ field:'id', title:'编号', width:150, checkbox:true },{ field:'name', title:'登陆名称', width:150, sortable:true }]], columns:[[{ field:'pwd', title:'密码', width:150, formatter: function(){ return:"****************" } }]] );
4. Confirmation dialog box:
$.messager.confirm('确认','你真的要删除吗?',function(data){ if(data){ } });
5. Edit to implement dynamic loading of the page
function editFun(){ var rows=$("#datagrid").datagrid("getChecked"); $('<p/>').dialog({ width:500, height:200, href:'${rootPath}/edit.jsp, modal:true, title:'编辑用户', buttons:[{ text:编辑, handler:function(){ $('#editForm').form('submit',{ url:'${rootPath}/user_edit.action', success:function(data){ var obj = JQuery.parseJSON(data); if(obj.success){ $('#edit_dialog').dialog('close'); } $.messager.show({ title:'提示', msg:obj.msg }); } } } }], onClose:function(){//必须写的 $(this).dialog('destroy'); }, onOpen:function(){ var data = rows[0]; }, onLoad:function(){//初始化数据,填充数据 var data = rows[0]; $("#editForm").form("load", data); } }); }
6. Update row
var rows=(‘#datagrid').datagrid(‘getChecked');(‘#datagrid').datagrid(‘updateRow',{ index:$(‘#datagrid').datagrid(‘getRowIndex',rows[0]), row:result.obj });
Has everyone mastered it? Collect it if you find it helpful.
Related recommendations:
Detailed explanation of jQuery EasyUI window usage examples
Implementing cross-row and cross-column tables in jQuery easyUI Method