Ext Object-Oriented development practice (cont.) _yui. Ext Related

Source: Internet
Author: User
To implement the data in a datasheet, the first step is to get the data from the data table, and we'll tweak the method of creating the store in the previous article to read the data from the datasheet.
Copy Code code as follows:

This.departmentstore = new Ext.data.JsonStore ({
Proxy:new Ext.data.HttpProxy ({url: "http://localhost:8080/Test_EXT/DB/Department.php"}),
Fields: ["Department_code", "Department_name", "manager", "Division_code"]
});

Department.php, is responsible for connecting the SQL database, taking the data and converting it to JSON format, to prepare for the ext read.
Copy Code code as follows:

<?php
Require (' json.php ');
Require (' uai_personal_info.php ');
$p = new Uai_personal_info ();
$result = $p->getdepartmentlist ();
$json = new Services_json ();
echo $json->encode ($result);
One more thing to change is the Onsubmitclick method for adding and modifying forms
Onsubmitclick:function () {
if (This.url!= "") {
This.form.submit ({url:this.url, success:this.onSubmit,
Waittitle: "Save Data", waitmsg: "transcation process ...", scope:this});
This.fireevent ("Submit", this, this.form.getValues ());
}
},

The Submit method needs to pass a series of parameters:
URL: The URL address for data processing, where a URL to handle the new action is passed in
Success: If the submission of data processing succeeds, the processing code specified by this parameter is recalled
Waittitle: Title of pop-up dialog box when data is submitted
Waitmsg: Information content of pop-up dialog box when data is submitted
Scope: This in the callback function refers to the object

The point to note here is that in the PHP file that processes the data, a JSON string must be returned, and if "Success:true" is included, the processing is or is not considered to be a failure. For example, the following code
Copy Code code as follows:

<?php
Require (' json.php ');
Require (' uai_personal_info.php ');
$rs = $_post;
$rs ["Success"] = true; Indicates successful processing
$sql = "INSERT into Uai_department (Department_code, Department_name, manager, Division_code) VALUES ('").
$_post["Department_code"]. "', '" . $_post["Department_name"]. "', '" . $_post["Manager". "', '" . $_post["Division_code"]. "')";
$p = new Uai_personal_info ();
$rs ["r"] = $p->insert_department ($sql);
$json = new Services_json ();
echo $json->encode ($RS);


The removal process is slightly different from the new and modified, because the deletion does not require the pop-up form to operate on the data, so we use the Ext.ajax object instead
Copy Code code as follows:

Remove:function () {
var r = This.getactiverecord ();
Ext.Ajax.request ({url: "http://localhost:8080/Test_EXT/DB/delete_dept.php", params: {Department_code:r.get (" Department_code ")});
This.getstore (). Remove (R);//delete client data
},

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.