Problems encountered in jquery easy ui datagrid..., jquery

Source: Internet
Author: User

Problems encountered in jquery easy ui datagrid..., jquery

If you don't want to talk about it, go directly to the next generation...
// Define a global change to prevent repeated submission (many people may encounter similar problems after Baidu)
1 var I = 0; 2 // modify 3 function Update () {4 // obtain the selected row 5 var selected = $ ("# dg1 "). datagrid ('getselected ');
// Determine whether the primary node has the option 6 if (selected! = Null) {7 // Add window 8 $ ('. theme-popover-mask '). fadeIn (100); 9 $ ('. theme-popover '). slideDown (200); 10 // initialization window content 11 $ ("# title "). text ("Modify information"); 12 $ ("# btnAdd "). hide (); 13 $ ("# btnUpdate "). show (); 14 $ ("# id "). val (selected. ID );
// The problem is that at the beginning, it is not useful to give the ID limit value of the selected bank to the hidden operation. It is always a problem of memory storage.
Instead, the model is directly merged. push ({ID: selected. ID, Grade: grade, State: state, UserName: username, PassWord: password, RegisterDate: registerdate. format ("yyyy-MM-dd hh: mm: ss ")});
In this case, the ID is the ID of the row selected for the first time. Therefore, the number of the row selected for the first time is 15 $ ("# username "). val (selected. userName); 16 $ ("# username "). attr ("disabled", "disabled"); 17 $ ("# username "). attr ("background-color", "# E0CACA"); 18 $ ("# password "). val (selected. passWord); 19 $ ("input [name = 'grade '] [value =" + selected. grade + "]"). attr ("checked", "checked"); 20 $ ("input [name = 'state'] [value =" + selected. state + "]"). attr ("checked", "checked"); 21 if (I = 0) {22 $ ("# btnUpdate "). click (function () {23 I ++; // you can press hour I ++ I = 0 to submit the statement to prevent re-commit 24 var model = []; 25 var id = $ ("# id "). val ();
// Retrieve the value of hidden and assign the value to the id. In this case, there is no above problem. I am also very sorry for the fact that there is no difference in the quality... But the value is different.
Model. push ({ID: id, Grade: grade, State: state, UserName: username, PassWord: password, RegisterDate: registerdate. format ("yyyy-MM-dd hh: mm: ss")}); 26 var username = $ ("# username "). val (); 27 var password =$ ("# password "). val (); 28 var grade = $ ("input [name = 'grad']: checked "). val (); 29 var state = $ ("input [name = 'state']: checked "). val (); 30 var registerdate = new Date (); 31 model. push ({ID: id, Grade: grade, State: state, UserName: username, PassWord: password, RegisterDate: registerdate. format ("yyyy-MM-dd hh: mm: ss")}); 32 // ajax asynchronous submission 33 $. ajax ({34 type: "post", 35 cache: false, // disable primary storage
37 url: "/Admin/Update? Time "+ (new Date ()). getTime (), // also prevents the producer from storing 38 data: {"data": JSON. stringify (model)}, // serialized json format submitted to success: function (data) {40 $ ('. theme-popover-mask '). fadeOut (100); 41 $ ('. theme-popover '). slideUp (200); 42 if (data = 1) {43 ds. dialog ({44 title: 'xin Xin hint ', 45 content:' congratulations, modification successful! ', 46 icon :'.. /.. /images/dsdialog/success.png '47}); 48} 49 else {50 ds. dialog ({51 title: 'xin Xin hint ', 52 content:' modified the error! ', 53 icon :'.. /.. /images/dsdialog/info.png '54}); 55} 56 // reload the datagrid57 $ ("# dg1 "). datagrid ('reload'); 58} 59 });
// End ajax60 // $. post ("/Admin/Update? Time "+ (new Date ()). getTime (), {"data": JSON. stringify (model)}, function (data) {61 // $ ('. theme-popover-mask '). fadeOut (100); 62 // $ ('. theme-popover '). slideUp (200); 63 // if (data = 1) {64 // ds. dialog ({65 // title: 'xin Xin hint ', 66 // content:' congratulations, modification successful! ', 67 // icon :'.. /.. /images/dsdialog/success.png '68 //}); 69 //} 70 // else {71 // ds. dialog ({72 // title: 'xin Xin hint ', 73 // content:' modified the error! ', 74 // icon :'.. /.. /images/dsdialog/info.png '75 //}); 76 //} 77 // $ ("# dg1 "). datagrid ('reload'); 78 //}); 79}); // end click80} 81} 82 else {83 ds. dialog ({84 title: 'xin Xin hint ', 85 content:' select the row to be modified! ', 86 icon:' ../images/dsdialog/info.png '87}); 88} 89}
1 // Delete 2 function Delete () {3 var selected = $ ("# dg1"). datagrid ('getselected'); 4 if (selected! = Null) {5 ds. dialog ({6 title: 'xin Xin hint ', 7 content:' Are you sure you want to delete the token? ', 8 icon:'.../../images/dsdialog/question.png ', 9 yesText: 'confirmed', 10 onyes: function (){
// However, This is okay when the primary node is deleted because the primary node does not have the last row selected, so the Update issue cannot occur. this problem does not occur when I add it. But what I do first is the division method. So I didn't think it would be a headache for haha... 11 $. post ("/Admin/Delete", {"Id": selected. ID}, function (data) {12 if (data = 1) {13 ds. dialog ({14 title: 'xin Xin hint ', 15 content:' congratulations, Division successful! ', 16 icon :'.. /.. /images/dsdialog/success.png '17}); 18} 19 else {20 ds. dialog ({21 title: 'xin Xin hint ', 22 content: 'Missing! ', 23 icon :'.. /.. /images/dsdialog/info.png '24}); 25} 26 $ ("# dg1 "). datagrid ('reload'); 27}); 28}, 29 noTest: 'delete', 30 onno: function () {31 this. close (); 32} 33}); 34} 35 else {36 ds. dialog ({37 title: 'xin Xin hint ', 38 content:' select the row to be deleted! ', 39 icon:' ../images/dsdialog/info.png '40}); 41} 42}
1 // format Date 2 Date. prototype. format = function (format) {3 var o = {4 "M +": this. getMonth () + 1, // month 5 "d +": this. getDate (), // day 6 "h +": this. getHours (), // hour 7 "m +": this. getMinutes (), // minute 8 "s +": this. getSeconds (), // second 9 "q +": Math. floor (this. getMonth () + 3)/3), // quarter10 "S": this. getMilliseconds () // millisecond11} 12 if (/(y + )/. test (format) format = format. replace (RegExp . $1, (this. getFullYear () + ""). substr (4-RegExp. $1. length); 13 for (var k in o) if (new RegExp ("(" + k + ")"). test (format) 14 format = format. replace (RegExp. $1, RegExp. $1. length = 1? O [k]: ("00" + o [k]). substr ("" + o [k]). length); 15 return format; 16}

Life is endless...

 

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.