JQuery MiniUI development tutorial CRUD: Form editing (3)

Source: Internet
Author: User

CRUD: In-row form editing

Reference example: CRUD: In-row form editing


I. Create an editing form

<Div id = "editForm1" style = "display: none; padding: 5px; position: relative;">
<Input class = "mini-hidden" name = "id"/>
<Table style = "width: 100%;">
<Tr>
<Td style = "width: 80px;"> employee account: </td>
<Td style = "width: 150px;"> <input name = "loginname" class = "mini-textbox"/> </td>
<Td style = "width: 80px;"> name: </td>
<Td style = "width: 150px;"> <input name = "name" class = "mini-textbox"/> </td>
<Td style = "width: 80px;"> salary: </td>
<Td style = "width: 150px;"> <input name = "salary" class = "mini-textbox"/> </td>
</Tr>
<Tr>
<Td> Gender: </td>
<Td> <input name = "gender" class = "mini-combobox" data = "Genders"/> </td>
<Td> Age: </td>
<Td> <input name = "age" class = "mini-spinner" minValue = "0" maxValue = "200" value = "25"/> </td>
<Td> Date of Birth: </td>
<Td> <input name = "birthday" class = "mini-datepicker"/> </td>
</Tr>
<Tr>
<Td style = "text-align: right; padding-top: 5px; padding-right: 20px;" colspan = "6">
<A class = "Update_Button" href = "javascript: updateRow ();"> Update </a>
<A class = "Cancel_Button" href = "javascript: cancelRow ();"> Cancel </a>
</Td>
</Tr>
</Table>
</Div>

Ii. Embed detailed rows

// Display row details
Grid. hideAllRowDetail ();
Grid. showRowDetail (row );
// Add the editForm element to the row detail cell.
Var td = grid. getRowDetailCellEl (row );
Td. appendChild (editForm );
EditForm. style. display = "";

3. Load the form

Var form = new mini. Form ("editForm1 ");
If (grid. isNewRow (row )){
Form. reset ();
} Else {
Form. loading ();
$. Ajax ({
Url: "../data/DataService. aspx? Method = GetEmployee & id = "+ row. id,
Success: function (text ){
Var o = mini. decode (text );
Form. setData (o); form. unmask ();
}
});
}

4. submit a form

Var form = new mini. Form ("editForm1 ");
Var o = form. getData (); grid. loading ("saving, please wait ......");
Var json = mini. encode ([o]);
$. Ajax ({
Url: "../data/DataService. aspx? Method = SaveEmployees ",
Data: {employees: json },
Success: function (text ){
Grid. reload ();
},
Error: function (jqXHR, textStatus, errorThrown ){
Alert (jqXHR. responseText );
}
});

Related Article

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.