色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

Ext面向?qū)ο箝_發(fā)實(shí)踐(續(xù))

要實(shí)現(xiàn)對(duì)數(shù)據(jù)表中的數(shù)據(jù)進(jìn)行操作,第一步就是要取得數(shù)據(jù)表中的數(shù)據(jù),我們把上篇文章中的創(chuàng)建Store的方法也略作調(diào)整,讓其從數(shù)據(jù)表中讀取數(shù)據(jù)。
復(fù)制代碼 代碼如下:
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,負(fù)責(zé)連接SQL數(shù)據(jù)庫(kù),取得數(shù)據(jù)并將其轉(zhuǎn)換為JSON格式,為Ext的讀取作準(zhǔn)備。
復(fù)制代碼 代碼如下:
<?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);
還有一點(diǎn)要修改的就是新增和修改窗體的onSubmitClick方法
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());
}
},

Submit方法需要傳遞一系列參數(shù):
url:數(shù)據(jù)處理的URL地址,這里傳入的是一個(gè)負(fù)責(zé)處理新增操作的URL
success:如果提交數(shù)據(jù)處理成功,則會(huì)回調(diào)這個(gè)參數(shù)指定的處理代碼
waitTitle:數(shù)據(jù)提交時(shí)彈出對(duì)話框的標(biāo)題
waitMsg:數(shù)據(jù)提交時(shí)彈出對(duì)話框的信息內(nèi)容
scope:回調(diào)函數(shù)中的this所指對(duì)象

這里需要說(shuō)明的是處理數(shù)據(jù)的php文件中,必須返回一個(gè)JSON字串,如果包含"success: true",則表示處理成或,否則認(rèn)為處理失敗。例如下面的代碼
復(fù)制代碼 代碼如下:
<?php
require('JSON.php');
require('uai_Personal_Info.php');
$rs = $_POST;
$rs["success"] = true; //表示處理成功
$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);


刪除的處理則與新增、修改略有不同,因?yàn)閯h除不需要彈出窗體對(duì)數(shù)據(jù)進(jìn)行操作,所以我們改用Ext.Ajax對(duì)象
復(fù)制代碼 代碼如下:
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); //刪除客戶端數(shù)據(jù)
},

JavaScript技術(shù)Ext面向?qū)ο箝_發(fā)實(shí)踐(續(xù)),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 北川| 浦县| 新竹市| 米泉市| 安西县| 平湖市| 漯河市| 延安市| 渝北区| 桃江县| 郧西县| 哈密市| 星子县| 黔西县| 根河市| 奎屯市| 孝义市| 瑞昌市| 固始县| 旬阳县| 夏河县| 井陉县| 黄石市| 崇仁县| 鹤壁市| 汝州市| 宁河县| 芮城县| 岱山县| 林芝县| 南陵县| 平武县| 深圳市| 鄂温| 南雄市| 阜新| 青河县| 乌拉特前旗| 如东县| 兰州市| 留坝县|