2011-01-05 60 views
0

我有一個網格,其中一列的總數將達到此總數並顯示在頁腳上。我設法做到了與:jqgrid - 如何從用戶數據中檢索值

$response->userdata['no'] = 'Total:'; 
    $response->userdata['amount'] = $total_amount; 

當用戶想添加一個記錄,我需要檢查用戶的金額字段中輸入的值不超過100

例如,現在讓我們說網格表有2個記錄行。記錄1的金額爲30,記錄2的金額爲50.因此,總計爲80.現在,用戶現在調用添加表單並在40中鍵入要添加的金額。當提交按鈕被點擊,錯誤信息應及時和記錄不會被添加,因爲總計超過100,如果用戶需要添加40

用戶無法提交,直到總被< = 100

我的問題是,如何檢索Total值並執行檢查,以使Total不會超過100?

謝謝。

亞歷

編輯:

var table_grid = jQuery("#my_table"); 

table_grid.jqGrid({ 
    url:'get.php', 
    datatype: 'json', 
    mtype: 'POST', 
    async: false, 
    colNames:['No','Amount'], 
    colModel:[ 
     {name:'no',index:'no',width:50,sortable:false,editable:false,editoptions:{readonly:true,size:10}}, 
     {name:'amount',index:'amount',align:'right',width:100,sortable:true,editable:true,formatter:'number'} 
    ], 
    footerrow : true, 
    userDataOnFooter : true 
}); 
+0

你也可以發佈電網代碼嗎? – 2011-01-05 03:48:55

+0

我已經添加了網格的代碼。我希望這就是你所指的。謝謝。 – Alex 2011-01-05 04:28:31

回答

1

我想通了。我們可以用這個檢索用戶數據:

userdata = (jQuery("#my_table").getUserData()); 

要訪問的價值,我們只是這樣做:

userdata.amount; 

我希望這會幫助別人。