Easyui data table export with DataGrid filter rows

Source: Internet
Author: User

Exporting data
/*
* ID DataGrid ID
* URL Action path
*/
function Exportexceltofilter (id,url) {
var filterrules = $ (' # ' +id). DataGrid (' Options '). Filterrules;
var params = $ (' # ' +id). DataGrid (' Options '). Queryparams;
for (var i = 0; i < filterrules.length; i++) {
var obj = filterrules[i];
if (Obj.field = = ' Applicationdate ') {
if (Obj.op = = ' Greater ') {
PARAMS.RDGT = Obj.value;
} else if (Obj.op = = ' less ') {
PARAMS.RDLT = Obj.value;
} else if (Obj.op = = ' equal ') {
PARAMS.RDGT = Obj.value;
PARAMS.RDLT = Obj.value;
}
}else{
Params[obj.field] = Obj.value;
}
}
Console.log (params);
var columnjsonf = $ (' # ' +id). DataGrid ("Options"). FrozenColumns;
var Columnjson = $ (' # ' +id). DataGrid ("Options"). Columns;
var form = $ (' <form></form> ');
Setting properties
Form.attr (' action ', URL);
Form.attr (' method ', ' post ');
The target property of the form determines on which page the form is submitted
_self-Current page _blank-new page
Form.attr (' target ', ' _self ');
Create input
var input = $ (' <input type= "hidden" name= "Columnjson"/> ");
var Inputrow = $ (' <input type= "hidden" name= "Rows" value= "/>");
var inputpage = $ (' <input type= "hidden" name= "page" value= "1"/> ');
Form.append (Inputrow);
Form.append (Inputpage);
var jsonarray=new Array ();
var arrayon=new Array ();
for (Var i=0;i<columnjsonf.length;i++)
{
for (Var j=0;j<columnjsonf[i].length;j++)
{
var col=columnjsonf[i][j];
Col.rowspan=columnjson.length;
Arrayon.push (COL);
}
}
for (Var i=0;i<columnjson.length;i++)
{
if (i==0) {
for (Var j=0;j<columnjson[i].length;j++)
{
var colj=columnjson[i][j];
Arrayon.push (COLJ);
}
Jsonarray.push (Arrayon);
}else{
Jsonarray.push (Columnjson[i]);
}
}

Alert (Json.stringify (Jsonarray));
Input.attr (' Value ', Json.stringify (Jsonarray));
Attach to form
Form.append (input);
Form.appendto ("body");
Form.css (' Display ', ' none ');
Submit Form
Form.form (' Submit ', {
Url:url,
Onsubmit:function (param) {
$.each (params, function (name, value) {
Param[name]=value;
});
}
});
Form.remove ();
}

Easyui data table export with DataGrid filter rows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.