Batch operations in ext JS grid checkbox gridpanel

Source: Internet
Author: User

 

<HTML> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "> <br/> <title> JSP page </title> <br/> <LINK rel =" stylesheet "type =" text/CSS "href =" extjs /resources/CSS/ext-all.css "mce_href =" extjs/resources/CSS/ext-all.css "/> <br/> <LINK rel =" stylesheet "type =" text/CSS "href = "jmaki-standard.css" mce_href = "jmaki-standard.css"/> <br/> <MCE: script Type = "text/JavaScript" SR C = "extjs/adapter/EXT/ext-base.js" mce_src = "extjs/adapter/EXT/ext-base.js"> </MCE: SCRIPT> <br/> <MCE: script Type = "text/JavaScript" src = "extjs/ext-all.js" mce_src = "extjs/ext-all.js"> </MCE: SCRIPT> <br/> <MCE: script Type = "text/JavaScript"> <! -- <Br/> var storefatlist; <br/> var cmfatlist; <br/> var gridfatlist; <br/> var Sm = new Ext. grid. checkboxselectionmodel (); <br/> Ext. onready (viewfatlist); <br/> function viewfatlist () <br/>{< br/> If (storefatlist = NULL) <br/>{< br/> storefatlist = new Ext. data. store ({<br/> Proxy: New Ext. data. httpproxy ({<br/> URL: 'auditusr. action '<br/>}), <br/> // create reader that reads the topic records <br/> reader: New Ext. data. jsonreader ({<br/> root: 'usrs ', <br/> totalproperty: 'totalcount', <br/> successproperty: 'success', <br/> ID: 'threadid', <br/> fields: [<br/> {Name: 'uid', mapping: 'uid', type: 'int '}, <br/> {Name: 'username', mapping: 'uname', type: 'string'}, <br/> {Name: 'email ', mapping: 'email ', type: 'string'}, <br/> {Name: 'status', mapping: 'state', type: 'int'} <br/>] <br/>}) <br/> }); <br/>}< br/> // The column model has information about grid columns <br/> // dataindex maps the column to the specific data field in <br/>/ /The data store <br/> If (cmfatlist = NULL) <br/>{< br/> cmfatlist = new Ext. grid. columnmodel ([<br/> SM, <br/> {<br/> header: "User Name", <br/> dataindex: 'uid' <br/> }, {<br/> header: "name", <br/> dataindex: 'username' <br/>},{ <br/> header: "email ", <br/> dataindex: 'email '<br/>},{ <br/> header: "status", <br/> dataindex: 'status' <br/>}]); <br/> cmfatlist. defaultsortable = true; <br/>}< br/> If (gridfatlist = NULL) <br/>{< br/> gridfatlist = new Ext. grid. gridpanel ({<br/> El: 'noauditusers', <br/> store: storefatlist, <br/> frame: True, <br/> width: 685, <br/> Height: 400, <br/> title: 'query result', <br/> collapsible: True, <br/> CM: cmfatlist, <br/> SM: Sm, <br/> trackmouseover: false, <br/> loadmask: false, <br/> tbar: New Ext. pagingtoolbar ({<br/> pagesize: 20, <br/> store: storefatlist, <br/> displayinfo: True, <br/> CLS: 'X-BTN-text-Icon details', <br/> displaymsg: 'displayed result {0}-{1}/{2}', <br/> emptymsg: "No matching record" <br/>}); <br/>}< br/> gridfatlist. render (); gridfatlist. collapse (true); <br/> storefatlist. load ({Params: {start: 0, limit: 20 }}); <br/>}< br/> // return the UID of the selected row <br/> function getfatselectedidarray () <br/>{< br/> var record = gridfatlist. getselectionmodel (). getselections (); <br/> If (record = NULL | record. length = 0) <br/> return NULL; <br/> var array = new array (record. length); <br/> for (VAR I = 0; I <record. length; I ++) <br/>{< br/> array [I] = record [I]. get ('uid'); <br/>}< br/> return array; <br/>}< br/> // response to the user-defined user button event <br/> function setdueuser () <br/>{< br/> array = getfatselectedidarray (); <br/> If (array = NULL) <br/>{< br/> alert ('select a user and then perform the operation'); <br/> return; <br/>}< br/> var info = ''; <br/> for (VAR I = 0; I <array. length; I ++) <br/>{< br/> info + = array [I] + ';'; <br/>}< br/> var conn = new Ext. data. connection (); <br/> // send an asynchronous request <br/> Conn. request ({<br/> // request address <br/> URL: 'executeaudit. action ', <br/> method: 'get', <br/> Params: 'uid =' + info, <br/> // specify the callback function <br/> callback: callback <br/>}); <br/> // callback function <br/> function callback (options, success, response) {<br/> If (SUCCESS) <br/>{< br/> If (response. responsetext. trim () = "1") <br/>{< br/> alert ('audit successfully'); <br/> storefatlist. reload (); <br/>}< br/> else <br/> alert ('Operation failed, Please retry '); <br/>}< br/> else <br/> alert ('Connection timed out, Please retry '); <br/>}< br/> function refreshdata () <br/>{< br/> setTimeout (function () <br/>{< br/> storefatlist. reload (); <br/>}, 1000); <br/>}</P> <p> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body> <br/> <Div id = "noauditusers"> </div> <br/> <input type = "button" onclick = "setdueuser (); "value =" Review "> <br/> </body> <br/> </ptml> 

 

 

Original article introduced from:

Http://www.unix-center.net/bbs/viewthread.php? Tid = 11088

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.