easyui中編輯單個儲存格,easyui編輯儲存格
<pre name="code" class="javascript"> var currentfield = undefined; var currentIndex = undefined; function onClickCell(rowIndex, field, value) { if (field != undefined) { if (currentIndex != undefined) { var ed = $('#grid').datagrid('getEditor', {index:currentIndex,field:currentfield}); var value=$(ed.target).datebox('getValue'); if(value&&value.length>0) { if (!value.match(/^((((19|20)\d{2})-(0?(1|[3-9])|1[012])-(0?[1-9]|[12]\d|30))|(((19|20)\d{2})-(0?[13578]|1[02])-31)|(((19|20)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))$/)) { $.messager.alert("提示", "時間格式有誤,資料復原!"); $('#grid').datagrid('rejectChanges'); coll = $('#grid').datagrid('getColumnOption', currentfield); coll.editor = null; currentIndex = undefined; currentfield = undefined; return; } } $("#grid").datagrid('endEdit', currentIndex); if (currentfield != undefined) { coll = $('#grid').datagrid('getColumnOption', currentfield); coll.editor = null; } var changes=$("#grid").datagrid("getChanges"); $('#grid').datagrid('acceptChanges'); var changedatas=JSON.stringify(changes); $.ajax({ type: 'post', dataType: 'json', data: {datas:changedatas}, url: '/FundPurchasingManagement/PurchasingExecEntering/UpdatePurchaseTaskPlan', async: false, error: function (request) { alert("Connection?error"); }, success: function (data) { if(!data.success) $.messager.alert('溫馨提示', data.msg, 'info'); } }) } col = $('#grid').datagrid('getColumnOption', field); col.editor = { type: 'datebox', options: { align: 'center'} }; $("#grid").datagrid('beginEdit', rowIndex); currentIndex = rowIndex; currentfield = field; } else { currentIndex = undefined; currentfield = undefined; } }
實現的效果為:
這是在datagrid中使用了datebox
怎編輯easyui datagrid 儲存格並儲存
acceptChanges
提交自從被載入以來或最後一次調用acceptChanges以來所有更改的資料。
text:'accept',iconCls:'icon-save',
handler:function(){
$('#tt').datagrid('acceptChanges');
}
easyui相同內容儲存格列不可以合并
多多看看api按照上面的指導例子做,能做出來,如果真的做不出來那就拼字串吧,把你想要的格式拼出來,就行了