Ext 대상 개발 실천(계속)

데이터 시트 의 데 이 터 를 조작 하려 면 첫 번 째 단 계 는 데이터 시트 의 데 이 터 를 얻 는 것 입 니 다.우 리 는 지난 글 에서 Store 를 만 드 는 방법 도 약간 조정 하여 데이터 시트 에서 데 이 터 를 읽 도록 합 니 다.

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 는 SQL 데이터 베 이 스 를 연결 하여 데 이 터 를 얻 고 JSON 형식 으로 변환 하여 Ext 의 읽 기 를 준비 합 니 다.

<?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);
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 방법 은 일련의 매개 변 수 를 전달 해 야 합 니 다.url:데이터 처리 URL 주소 입 니 다.여기 서 들 어 오 는 것 은 새로 추 가 된 작업 을 처리 하 는 URL success 입 니 다.데이터 처리 가 성공 하면,이 매개 변수 가 지정 한 처리 코드 waitTitle:데이터 제출 시 팝 업 대화 상자 의 제목 waitMsg:데이터 제출 시 팝 업 대화 상자 의 정보 내용 scope:리 셋 함수 의 this 가 가리 키 는 대상 은 데 이 터 를 처리 하 는 PHP 파일 에서 JSON 문자열 을 되 돌려 야 합 니 다."success:true"가 포함 되 어 있 으 면 처리 되 거나,그렇지 않 으 면 처리 가 실패했다 고 생각한다.예 를 들 어 아래 코드

<?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);
에서 삭 제 된 처 리 는 새로 추 가 된 것,수정 한 것 과 약간 다 릅 니 다.팝 업 창 이 데 이 터 를 조작 할 필요 가 없 기 때문에 저 희 는 Ext.ajax 대상

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); //
},
으로 바 꿉 니 다.

좋은 웹페이지 즐겨찾기