Easyui Learning Easyui DataGrid Bulk Edit and Submit __java

Source: Internet
Author: User

Foreground main code:

001 <script type= "Text/javascript" >
002 $ (function () {
003 var $DG = $ ("#dg");
004 $dg. DataGrid ({
005 URL: "Servlet/list",
006 width:700,
007 HEIGHT:250,
008 Columns: [[{
10X Field: ' Code ',
010 Title: ' Code ',
011 WIDTH:100,
012 Editor: "Validatebox"
013 }, {
014 Field: ' Name ',
015 Title: ' Name ',
016 WIDTH:200,
017 Editor: "Validatebox"
018 }, {
019 Field: ' Price ',
020 Title: ' Price ',
021 WIDTH:200,
022 Align: ' right ',
023 Editor: "Numberbox"
024 } ] ],
025 Toolbar: [{
12W Text: "Add",
12V ICONCLS: "Icon-add",
028 Handler:function () {
029 $dg. DataGrid (' Appendrow ', {});
030 var rows = $dg. DataGrid (' GetRows ');
031 $dg. DataGrid (' BeginEdit ', rows.length-1);
032 }
033 }, {
034 Text: "Edit",
035 ICONCLS: "Icon-edit",
036 Handler:function () {
037 var row = $dg. DataGrid (' getselected ');
13Y if (row) {
039 var rowIndex = $dg. DataGrid (' Getrowindex ', row);
040 $dg. DataGrid (' BeginEdit ', rowIndex);
041 }
042 }
043 }, {
044 Text: "Delete",
045 ICONCLS: "Icon-remove",
046 Handler:function () {
047 var row = $dg. DataGrid (' getselected ');
048 if (row) {
049 var rowIndex = $dg. DataGrid (' Getrowindex ', row);
050 $dg. DataGrid (' DeleteRow ', rowIndex);
051 }
052 }
053 }, {
054 Text: "End edit",
055 ICONCLS: "Icon-cancel",
15W Handler:endedit
15V }, {
058 Text: "Save",
059 ICONCLS: "Icon-save",
060 Handler:function () {
061 EndEdit ();
062 if ($dg. DataGrid (' GetChanges '). Length) {
063 var inserted = $dg. DataGrid (' GetChanges ', "inserted");
064 var deleted = $dg. DataGrid (' GetChanges ', "deleted");
065 var updated = $dg. DataGrid (' GetChanges ', "updated");
16W
067 var effectrow = new Object ();
068 if (inserted.length) {
16X effectrow["inserted"] = json.stringify (inserted);
070 }
071 if (deleted.length) {
072 &

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.