Show Posts
|
Pages: 1 2 [3] 4
|
32
|
General Category / EasyUI for jQuery / This getChanges is no data after open the datagrid enableCellEditing option.
|
on: February 08, 2016, 04:41:09 AM
|
I want get the getchanges of the datagrid after appendRow,editRow or deleteRow. but here is no changes data return,
My code:
<script>
initbillgrid();
$(function () { $('#griddetail').datagrid().datagrid('enableCellEditing'); })
var editIndex = undefined; var detailvalid = true;
$(function () { bindData(); });
function bindData() { $('#griddetail').datagrid({ title: '', url: '/Stocks/PORequest/DetailReload', method: 'get', dataType: "json", fit: true, toolbar: '', fitColumns: true, rownumbers: true, striped: true, autoRowHeight: false, pageSize: 10000, pagination: false, remoteSort: false, idField: 'peid', columns: [[ { field: 'peid', hidden: true, title: 'ID' }, { field: 'materialid', hidden: true, title: 'materialid' }, { field: 'mrpid', hidden: true, title: 'mrpid' }, { field: 'unitid', hidden: true, title: 'unitid' }, { field: 'pounitid', hidden: true, title: 'pounitid' }, { field: 'ma_code', title: 'Code', width: '110px', sortable: true }, { field: 'ma_name', title: 'Name', width: '120px', sortable: true }, { field: 'qty', title: 'Quantity', width: '100px', editor: { type: 'text', options: { required: true } } }}, ]], queryParams: { formid: '1', masterid: '1' }, singleSelect: true, onLoadSuccess: function (data) { }, toolbar: [{ text: 'Add', iconCls: 'icon-table_add', handler: function () { appendDetail(); } }, '-', { text: 'Delete', iconCls: 'icon-table_delete', handler: function () { removeit(); } }], onClickRow: function (rowIndex, rowData) { editIndex = rowIndex; } }); }
function appendDetail() { dlgMaterialMultiple(); }
function dlgMaterialMultipleInfor(checkedRows) { var rows = $('#griddetail').datagrid('getData'); rows = rows.total + 1; $.each(checkedRows, function (n, value) { $('#griddetail').datagrid('appendRow', { peid: '-1', materialid: value.maid, mrpid: '0', unitid: value.unitid, pounitid: value.unitidpo, ma_code: value.macode, ma_name: value.maname, ma_model: value.mamodel, mu_name: value.unitponame, precision: value.precision, qty: parseFloat('1').toFixed(value.precision), ftpurchtime: '@ViewBag.AfterDate' }); editIndex = $('#griddetail').datagrid('getRows').length - 1; $('#griddetail').datagrid('endEdit', editIndex); }); }
function removeit() { if (editIndex == undefined) { return } $('#griddetail').datagrid('cancelEdit', editIndex).datagrid('deleteRow', editIndex); editIndex = undefined; }
function accept() { $('#griddetail').datagrid('acceptChanges'); }
function postData() { accept(); var inserted = $('#griddetail').datagrid('getChanges', "inserted"); var deleted = $('#griddetail').datagrid('getChanges', "deleted"); var updated = $('#griddetail').datagrid('getChanges', "updated");
var rowsCh = $('#griddetail').datagrid('getChanges'); console.log(rowsCh); }
function initbillgrid() { (function ($) { function nav(target) { var dg = $(target); var opts = dg.datagrid('options'); dg.datagrid('getPanel').attr('tabindex', 1).css('outline-style', 'none').unbind('.cellediting').bind('keydown.cellediting', function (e) { switch (e.keyCode) { case 37: // left gotoCell(target, 'left'); break; case 39: // right gotoCell(target, 'right'); break; case 38: // up gotoCell(target, 'up'); break; case 40: // down gotoCell(target, 'down'); break; case 13: // enter var cell = $(this).find('td.datagrid-row-selected'); if (cell.length) { var field = cell.attr('field'); var index = cell.closest('tr.datagrid-row').attr('datagrid-row-index'); dg.datagrid('editCell', { index: index, field: field }); } break; } return false; }); }
function gotoCell(target, p) { var dg = $(target); var opts = dg.datagrid('options'); var cell = dg.datagrid('getPanel').find('td.datagrid-row-selected'); if (typeof p == 'object') { cell.removeClass('datagrid-row-selected'); cell = opts.finder.getTr(target, p.index).find('td[field="' + p.field + '"]'); cell.addClass('datagrid-row-selected'); return; } if (!cell) { return; } var field = cell.attr('field'); var tr = cell.closest('tr.datagrid-row'); var index = parseInt(tr.attr('datagrid-row-index')); var td = cell; if (p == 'up' && index > 0) { td = opts.finder.getTr(dg[0], index - 1).find('td[field="' + field + '"]'); } else if (p == 'down' && index < dg.datagrid('getRows').length - 1) { td = opts.finder.getTr(dg[0], index + 1).find('td[field="' + field + '"]'); } else if (p == 'left') { td = td.prev(); } else if (p == 'right') { td = td.next(); } if (td.length) { dg.datagrid('scrollTo', td.closest('tr.datagrid-row').attr('datagrid-row-index')); cell.removeClass('datagrid-row-selected'); td.addClass('datagrid-row-selected'); } }
function editCell(target, param) { var dg = $(target); var opts = dg.datagrid('options'); var fields = dg.datagrid('getColumnFields', true).concat(dg.datagrid('getColumnFields')); $.map(fields, function (field) { var col = dg.datagrid('getColumnOption', field); col.editor1 = col.editor; if (field != param.field) { col.editor = null; } }); dg.datagrid('endEdit', param.index); dg.datagrid('beginEdit', param.index); opts.editIndex = param.index; var ed = dg.datagrid('getEditor', param); if (ed) { var t = $(ed.target); if (t.hasClass('textbox-f')) { t = t.textbox('textbox'); } t.focus(); t.bind('keydown', function (e) { if (e.keyCode == 13) { dg.datagrid('endEdit', param.index); gotoCell(target, param); dg.datagrid('getPanel').focus(); } else if (e.keyCode == 27) { dg.datagrid('cancelEdit', param.index); gotoCell(target, param); dg.datagrid('getPanel').focus(); } e.stopPropagation(); }); } $.map(fields, function (field) { var col = dg.datagrid('getColumnOption', field); col.editor = col.editor1; }); }
function enableCellEditing(target) { var dg = $(target); var opts = dg.datagrid('options'); opts.oldOnClickCell = opts.onClickCell; opts.onClickCell = function (index, field) { if (opts.editIndex != undefined) { if (dg.datagrid('validateRow', opts.editIndex)) { dg.datagrid('endEdit', opts.editIndex); opts.editIndex = undefined; } else { return; } } dg.datagrid('selectRow', index).datagrid('editCell', { index: index, field: field }).datagrid('gotoCell', { index: index, field: field }); opts.oldOnClickCell.call(this, index, field); }; opts.onBeforeSelect = function () { return false; }; }
$.extend($.fn.datagrid.methods, { editCell: function (jq, param) { return jq.each(function () { editCell(this, param); }); }, gotoCell: function (jq, param) { return jq.each(function () { gotoCell(this, param); }); }, enableCellEditing: function (jq) { return jq.each(function () { nav(this); enableCellEditing(this); }); } });
})(jQuery); } </script>
|
|
|
33
|
General Category / EasyUI for jQuery / How can formatter the datagrid row value.
|
on: February 05, 2016, 08:05:47 AM
|
I want to format the quantity cell for dynamic. like 1 row, the precision value is 2, When input the quantity=10,the quantity cell display 10.00 2 row, the precision value is 3, When input the quantity=11,the quantity cell display 11.00 columns: [[ { field: 'peid', hidden: true, title: 'ID' }, { field: 'code', title: 'Code', width: '110px', sortable: true }, { field: 'name', title: 'Name', width: '120px', sortable: true }, { field: 'model', title: 'Model', width: '140px', sortable: true }, { field: 'precision', title: 'Precision', width: '70px' }, { field: 'qty', title: 'Quantity', width: '100px', editor: { type: 'numberbox', options: { required: true, formatter: function (value, row, index) { return parseFloat(value).toFixed(row.precision); } } } },
|
|
|
34
|
General Category / EasyUI for jQuery / Uncaught TypeError: Cannot read property 'panel' of undefined
|
on: February 02, 2016, 11:09:42 PM
|
return _5d2(jq[0]); },getPanel:function(jq){ return $.data(jq[0],"datagrid").panel; },getPager:function(jq){ [b]return $.data(jq[0],"datagrid").panel.children("div.datagrid-pager");[/b] },getColumnFields:function(jq,_760){ return _627(jq[0],_760); },getColumnOption:function(jq,_761){ return _628(jq[0],_761); },resize:function(jq,_762){ return jq.each(function(){ _5e1(this,_762);
|
|
|
35
|
General Category / EasyUI for jQuery / Uncaught TypeError: Cannot read property 'options' of undefined
|
on: February 01, 2016, 11:10:52 PM
|
<div id="tb" style="padding:0px;height:auto"> <div class="pagepanelheader"> <a id="btnOk" href="#" class="easyui-linkbutton" iconcls="icon-ok" plain="true" onclick="doOkPage('0')">OK</a> <a id="btnClear" href="#" class="easyui-linkbutton" iconcls="icon-undo" plain="true" onclick="doOkPage('1')">Clear</a> </div> <div> Code: <input id="btnum" class="easyui-textbox pagetextbox" type="text"> Name: <input id="btnname" class="easyui-textbox pagetextbox" type="text"> Status:<select id="comstatus1" class="easyui-combobox" editable="false" disabled="disabled" name="state" style="width:70px;"> <option value="-1">All</option> <option value="0" selected="selected">Normal</option> <option value="1">Expire</option> </select> <a id="btnLoad" href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="doSearchPage()">Query</a> </div> </div>
<div id="gridmaster"></div>
function _9ac(_9b2,_9b3,_9b4){ [b]var opts=$.data(_9b2,"combobox").options;[/b] var _9b5=$(_9b2).combo("panel"); if(!$.isArray(_9b3)){ _9b3=_9b3.split(opts.separator); }
|
|
|
38
|
General Category / EasyUI for jQuery / The datagrid updateRow and getChanges problem.
|
on: November 03, 2015, 01:03:51 AM
|
Hi,Master. I need to change the cell value when I double click the datagrid row,but if i call the getChanges method after this,I don't see the cell modified by program in the list. I had search the question by google,but none answer about this. Can anybody tell me how can I fix this? Thanks var updated = $('#griddetail').datagrid('getChanges', "updated"); columns: [[ { field: 'wfd_id', hidden: true, title: 'ID' }, { field: 'emname_st', title: 'Name', width: '80px' }, { field: 'deptname', title: 'Department', width: '80px' }, { field: 'condition1', title: 'Condition1', width: '100px', editor: { type: 'text', options: { required: true } } }, { field: 'condition2', title: 'Condition2', width: '100px', editor: { type: 'text', options: { required: true } } } ]], onDblClickRow: function (rowIndex, rowData) { doeditRow(rowIndex, rowData); }
function doeditRow(rowIndex, rowData) { $('#griddetail').datagrid('selectRow', editIndex) .datagrid('beginEdit', editIndex); $('#griddetail').datagrid('updateRow', { index: editIndex, row: { condition1:'1', deptname: 'New Name', } }); }
|
|
|
41
|
General Category / EasyUI for jQuery / One datagrid more checkbox columns
|
on: October 14, 2015, 02:20:13 AM
|
There one datagrid, and two or more than two checkbox columns. When I check the ck row,but the ck2 columns is checked at the same time. why? columns: [[ { field: 'sysfunid', hidden: true, title: 'ID' }, { field: 'sysfunnumber', title: 'sysfunnumber', width: '120px', sortable: true }, { field: 'ck', checkbox: true }, { field: 'ck2', checkbox: true }, ]],
|
|
|
42
|
General Category / EasyUI for jQuery / How can get the window href url parameters?
|
on: October 12, 2015, 06:56:23 PM
|
Two pages. Such as 'A.html' and 'B.html', A.html have a windows div, the id name is 'emwindows'. when I click the button. The 'B.html' popup, I want to get the B.html url parameters on B.html. How can do it? <a href="#" class="easyui-linkbutton" style="width:20px;height:20px;" onclick="dlgEmploye()">...</a>
<div id="emwindows" class="easyui-window" closed="true" title="My Window" style="width:0px;height:0px"></div>
function dlgEmploye() { $("#emwindows").empty(); var $win; $win = $("#emwindows").window({ width: 700, height: 500, modal: true, href: 'B.html?formid=abc&pmodel=id_name&cid=xyz&cname=123', title: 'Choice', collapsible: false, maximizable: true, minimizable: false, onResize: function () { $(this).window('center'); } }); $win.window('open'); }
|
|
|
45
|
General Category / EasyUI for jQuery / Re: DataGrid checkbox question.
|
on: October 06, 2015, 04:32:19 PM
|
If you set the 'checked' value with 'true' or 'false', you get a string value. A non-empty string evaluates to true.
No, If set the 'checked' value with false or 'false' the result is different.the id=4 and id=5 is different work. When id=4 the checkbox is checked,when id=5 the checkbox is not checked.Please note the single quotes. You can test it. Thanks. var data = [ { id: 1, sysfunnumber: 'sysfunnumber1' }, { id: 2, sysfunnumber: 'sysfunnumber2', checked: 'true' }, { id: 3, sysfunnumber: 'sysfunnumber3', checked: 'true' }, { id: 4, sysfunnumber: 'sysfunnumber4', checked:'false' }, { id: 5, sysfunnumber: 'sysfunnumber5', checked: false } ]
|
|
|
|