DHTMLX 前端架構 建立你的一個應用程式 教程(六)-- 表格載入資料

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   ar   使用   sp   檔案   

 

從資料庫載入資料

 

  這篇我們介紹從MySQL資料庫中載入資料到表格

  

  

  我們使用 MySql的資料庫dhtmlx_tutorial 和表contacts

 

  樣本使用的是PHP平台和dhtmlxConnector 協助庫  因為這是實現伺服器端邏輯最簡單的方法   資料以XML格式輸出。

 

  環境自己搭建  相信C#的朋友 從資料庫擷取資料轉化盛XML也不是難事。

 

 

載入資料到表格:

 

  1.找到”db.sql“檔案將表匯入到本機資料庫

  2.在codebase 檔案中添加一個php檔案codebase

  3.下載dhtmlxConnector 庫 (下載連結)

  4.在codebase檔案夾中添加connector檔案夾

  5.在data檔案中添加contacts.php

  

  

  6.在contacts.php中添加php代碼

  

<?phprequire("../codebase/connector/grid_connector.php");//adds the connector engine$res=mysql_connect("localhost","user","password");//connects to server with  dbmysql_select_db("dhtmlx_tutorial");//connects to db with name "dhtmlx_tutorial"   $conn = new GridConnector($res);             //initializes the connector object$conn->render_table("contacts","contact_id","fname,lname,email");  //loads data//the method takes: the table‘s name, the id field, a list of fields to load

  

  擷取從資料庫載入資料和建立XML的細節 參考 動態載入大資料

 

  7.使用load() 方法載入資料到表格

  

contactsGrid.load("data/contacts.php");

 

  dhtmlx.js已經包含了 dhtmlxConnector  方法 ,所以我們不必再額外引入其他檔案。

 

  

DHTMLX 前端架構 建立你的一個應用程式 教程(六)-- 表格載入資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.