jquery MINIUI Study Notes

Source: Internet
Author: User

1. Take component value pass form data,load send request load data
<script type= "Text/javascript" >
Mini.parse ();
Get grid
var Grid = Mini.get ("grid");
var form = new Mini. Form ("#form");
function Search () {
Gets the value of an ID component
var rq = mini.get ("YF"). GetValue ();
if (RQ) {
Pass the parameters and values in the form to the request sent by the grid
Grid.load (Form.getdata (true));
} else {
Mini.alert ("Please select");
}
}
</script>

2.
Confirm OK Box OK title, Options, Execute method
function cz () {
\ \ Get grid selected row (radio)
var row = grid1.getselected ();
if (row) {
Mini.confirm ("Confirm calculation?") ",
Determine ",
Function (action) {
\\action Options
if (action = = "OK") {
var jhzt = ' 10 ';
var flbm = mini.get ("FLBM"). GetValue ();
\\ok sends an AJAX request to perform the operation
$.ajax ({
URL: "${pagecontext.request.contextpath}/js/cz.action",
Type: "POST",
Data: {
FLBM:FLBM,
Pzh:row.pzh,
Jhzt:jhzt
},
Success:function (text) {
Mini.alert ("Operation succeeded!");
\ \ Reload Data
Grid.reload ();
},
Error:function (text) {
Mini.alert ("Operation failed!");
}
});
} else {
}
});
} else {
\ \ If no data is selected, the message pops up
Mini.alert ("Please select a piece of data");
}
}

3. Renderer
<div field= "tjskg" name= "tjskg" allowsort= "true" renderer= "Onactionrenderer" > Buttons </div>
<script type= "Text/javascript" >
function Onactionrenderer (e) {
var Grid = E.sender;
var record = E.record;
var uid = record._uid;
var column = E.column;
var s = ' <a class= ' Mini-button "onclick=" js (\ ' + uid + ' \ ') "> ' +e.value+ ' </a> ';
return s;
}

</script>

 4. Data into JSON, submit form
 //Submit form data
 var form = new Mini. Form ("#form1");             
 var data = Form.getdata ();     //Get the data for multiple controls on the form
 var JSON = mini.encode (data);  // Serialize to JSON
 $.ajax ({
     URL: ".. /data/formservice.aspx?method=savedata ",
     Type:" Post ",
     Data: {Submitdata:json},
     success:function (text) {
     & nbsp;   alert ("Submit successful, return result:" + text);
    }
 });

5.json deserialization into an object
Load form
$.ajax ({
URL: ".. /data/formservice.aspx?method=loaddata ",
Type: "Post",
Success:function (text) {
var data = Mini.decode (text); Deserialization into an object
Form.setdata (data); Setting up multiple control data
}
});

6. Send AJAX requests, generate table, set TD cross-row cross-column properties
function SetData (data) {
data = Mini.clone (data);
var sbjgbh = DATA.SBJGBH;
var jsrq = DATA.JSRQ;
var compname = Data.compname;
var n = jsrq.substring (0, 4);
var y = jsrq.substring (4, 6);
$.ajax ({
URL: "${pagecontext.request.contextpath}/jh/dd.action",
Type: "POST",
Data: {
SBJGBH:SBJGBH,
Jsrq:jsrq
},
Success:function (data) {
if (data.success = = True) {
var result = Data.result;
var colnamef = [' Zs ', ' mz ', ' zy ', ' cwz ',
' Cwmz ', ' cwzy ', ' Zcz ', ' zcmz ', ' Zczy ',
' Zqz ', ' zqmz ', ' Zqzy '];
document.getElementById ("Jsrq"). InnerHTML = "&nbsp;"
+ N + "year" + "&nbsp;" + y + "month";
document.getElementById ("Compname"). InnerHTML = "Agency (name):"
+ Compname;
Insertrowsintospace (RESULT,COLNAMEF, "tbody1");
}
},
Error:function (data) {
Mini.alert ("Data failed to pass!") ");
}
});
}

function Insertrowsintospace (DATA,COLNAMEF,
TABLENAMEF) {
for (var i = 0; i < data.length; i++) {
var row = document.createelement ("tr");
for (var j = 0; J < Colnamef.length; J + +) {
var colume = document.createelement ("TD");
var key = Colnamef[j];
var value = Data[i][key];
Colume.appendchild (document.createTextNode (value));
Row.appendchild (Colume);
}
Table.appendchild (row);
}
var row = document.createelement ("tr");
var colume = document.createelement ("TD");
colume.innerhtml = ' remark ';
colume.colspan=12;
Colume.setattribute ("RowSpan", "2");
Colume.setattribute ("ColSpan", "12");
colume.style.csstext= "border:0px;";
Row.appendchild (Colume);
Table.appendchild (row);
}
7. Initialization interface and data SetData
function SetData (data) {
Data objects that are passed across pages and are cloned before they can be used safely
data = Mini.clone (data);
flag = Data.flag;
WBWJM = DATA.WBWJM;
Mini.get (' flag '). SetValue (flag);
Mini.get (' WBWJM '). SetValue (WBWJM);
}

8. Select multiple rows to take a column parameter value in the row

The push usage of jquery, which adds one or more elements to the end of the array, and returns the new length,

var rows = grid.getselecteds ();
            if (rows.length > 0) {
                 if (Confirm ("OK to delete selected records?") ")) {
                     var ids = [];
                     for (var i = 0, L = rows.length; i < L; i++) {
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&N bsp;              var r = rows[i];


Ids.push (r.id);
}

Add a delimiter to an array
var id = ids.join (', ');
Grid.loading ("In action, please later ...");
$.ajax ({
URL: ".. /data/ajaxservice.aspx?method=removeemployees&id= "+id,
Success:function (text) {
Grid.reload ();
},
Error:function () {
}
});
}
} else {
Alert ("Please select a record");
}

12.datagrid displays columns with decimals, for example with two decimal places

12.1 <div field= "Salary" numberformat= "¥#,0.00" align= "right" width= "" allowsort= "true" > Payroll </div>
<div field= "Age" Width= "allowsort=" true "decimalplaces=" 2 "datatype=" float "> Ages </div>

12.2 datatype= "float" + numberformat= "N2"

12.3 datatype= "Currency"

jquery MINIUI Study Notes

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.