tabalinas/jsgrid

insertItem - jsGrid does not show up newly inserted row data

開放

#1,061 建立於 2018年3月12日

 (5 則留言) (0 個反應) (0 位負責人)JavaScript (356 個分叉)batch import
help wanted

倉庫指標

星標
 (1,520 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Form data successfully posted and gets updated in database. But newly inserted data does not show up in jsGrid, instead blank row is shown. Checked response separately and the controller returns newly inserted record in JSON format. Also tried with "return $.ajax" and "$.ajax", no luck in getting the data displayed in jsGrid, after browser refresh it shows up the newly inserted data. Not sure what am I missing, please help.

#--- Python  Controller `-----#`
@app.route('/user', methods=['POST'])
def add_user():
    user = mongo.db.user_mgmt
    new_user = []
    user_id = user.insert({'usr_nm':request.form['UserName'],
                           'psswd':request.form['Password'],
                           'isAdmin':request.form['isAdmin']})
    for usr in user.find({'_id':user_id}):
        new_user.append({
            'ID':str(usr['_id']),
            'UserName':usr['usr_nm'],
            'psswd':usr['Password'],
            'isAdmin':usr['isAdmin']})
    return jsonify(new_user)
//--- jsGrid client ----//
insertItem: function (item) {
	return $.ajax({
		type: "POST",
		url: "/user",
		data: item
	});
},

貢獻者指南