0

私は datatable を持っており、1 つの列が編集可能です。3つの問題の解決策を探しています。誰でもこれを手伝ってもらえますか。

  1. 最初の列をサーバー側スクリプト (DB の主キー) に渡す必要があります。
  2. 1つのセルだけを不変にする必要があります(最初の行、最初の列の要素)
  3. テーブルを編集した後、編集した値を列に表示する必要があります。sUpdateURL: function(value, settings) を使用すると、変更が表示されます。誰でもこれについて私を助けることができますか?私はデータテーブルに非常に慣れていません。

これが私のコードです

$(document).ready(function() {
        $('#jtable').html( '<table cellpadding="1" cellspacing="1" border="1" class="pretty" id="edit_table"></table>' );
        $("#edit_table").dataTable({
            "aaData": {{ result | safe }},
            "aLengthMenu" : 100,
            "aaSorting": [],
            "aoColumns" : [
                {'sTitle' : 'Options' },
                {'sTitle' : 'Values'}
            ],
            "iDisplayLength": -1,
            "bFilter" : false,
            "bSearchable" :false,
            "bInfinite" :true,
            "bSort" :false,
            "bPaginate": false
        });
    });
    $(document).ready(function(){
        $("#edit_table").dataTable().makeEditable({
             sUpdateURL: "/submitchanges",
            "aoColumns": [
                null,
                {
                },
                {
                    indicator: 'Saving platforms...',
                    tooltip: 'Click to edit platforms',
                    type: 'textarea',
                    submit:'Save changes',
                    fnOnCellUpdated: function(sStatus, sValue, settings){

                    }
                }
            ]
        });
    });

サーバー側の処理に python + フラスコ フレームワークを使用しています。

4

1 に答える 1

0

ここに、クライアント側で機能するサーバーコードがあります(わずかに変更されています。以下を参照してください)。

from flask import Flask, render_template, request as flask_request
app = Flask(__name__)

@app.route('/')
def hello_world():
    aa_data = [['First', 'Second'], ['First', 'Second']]
    return render_template('index.html', result = aa_data)

@app.route('/update/', methods=['POST'])
def update_records():
    value = flask_request.form['value']
    row_id = flask_request.form['rowId']
    # todo: perform database update operation
    return value

if __name__ == '__main__':
    app.run(debug=True)

クライアント側の変更:

$("#edit_table").dataTable().makeEditable({
            sUpdateURL: "/update/",
            "aoColumns": [
                null,
                {
                    sName:"secondColumn"
                }
            ]
        });
于 2013-02-20T09:15:47.587 に答える