4

まず、私の英語が下手でごめんなさい!

私は次のものを作る必要があります: ExtJS 3.4 Editable Grid ()、json 形式で動作します。入力ソースはjson形式です。例のように、すべてうまくいきました。

やった:

  1. PHPでデータベースから配列にデータをダウンロードする
  2. 配列はjson形式にエンコードされます
  3. 編集可能なグリッド ソースは、json メッセージを含むページであり、現在はすべて正常に機能しています。

今、私はこれを行う必要があります: グリッドでセルを更新する際に、データベースのデータを更新する必要があります。

これどうやってするの?ウェブで何も見つかりませんでした。
delphi7 のような 'OnCellEditting' のようなメソッドがあるのではないでしょうか?

私のjsコード:

Ext.onReady(function () {
    function formatDate(value) {
        return value ? value.dateFormat('M d, Y') : '';
    }

    // shorthand alias
    var fm = Ext.form;

    // the column model has information about grid columns
    // dataIndex maps the column to the specific data field in
    // the data store (created below)
    var cm = new Ext.grid.ColumnModel({
        // specify any defaults for each column
        defaults: {
            sortable: false // columns are not sortable by default           
        },
        columns: [{
            header: 'ID',
            dataIndex: 'id',
            width: 30
        }, {
            id: 'firstname',
            header: 'Firstname',
            dataIndex: 'firstname',
            width: 220,
            // use shorthand alias defined above
            editor: new fm.TextField({
                allowBlank: false
            })
        }, {
            header: 'Lastname',
            dataIndex: 'lastname',
            width: 220,
            // use shorthand alias defined above
            editor: new fm.TextField({
                allowBlank: false
            })
        }]
    });

    // create the Data Store
    var store = new Ext.data.JsonStore({
        totalProperty: 'total', // total data, see json output
        root: 'results', // see json output
        url: '/grid/json',
        fields: [
            'firstname', 'lastname']
    });

    // create the editor grid
    var grid = new Ext.grid.EditorGridPanel({
        store: store,
        cm: cm,
        renderTo: 'grid-editable',
        width: 440,
        height: 300,
        autoExpandColumn: 'firstname', // column with this id will be expanded
        title: 'Edit Plants?',
        frame: true,
        clicksToEdit: 1
    });

    // manually trigger the data store load
    store.load({
        // store loading is asynchronous, use a load listener or callback to handle results

    });
});
4

1 に答える 1