- 注册时间
- 2013-2-1
- 最后登录
- 2013-2-2
- 阅读权限
- 10
- 积分
- 11
- 精华
- 0
- 帖子
- 3
|
我的代码是想在grid可编辑行里,点击物料编码 ,就是一个btnEdit控件,弹出窗口里选择一行信息,返回给grid当前行,赋值给行里的几个列。
<script type="text/javascript">
function onButtonSelect(e) {
var btnEdit = this;
mini.open({
url: bootPATH + "../test/SelectMattrial.htm",
title: "选择列表",
width: 650,
height: 380,
ondestroy: function (action) {
//if (action == "close") return false;
if (action == "ok") {
var iframe = this.getIFrameEl();
var datas = iframe.contentWindow.GetData();
if (datas != null) {
var row = grid.getSelected();
//再接下来不知道怎么写了?我想把datas.codenum赋值给grid第三列,怎么写呢?
}
}
}
});
}
</script>
<div id="datagrid1" class="mini-datagrid" style="width:1020px;height:280px;"
url="testmodel.aspx?method=SearchVoid" multiSelect="true" allowResize="true"
>
<div property="columns">
<div type="checkcolumn"></div>
<div field="CodeNum" allowResize="false" width="120" headerAlign="center" allowSort="true">物料编码
<input property="editor" id="Text1" class="mini-buttonedit" style="width:100%;" name="a" textName="b"/>
</div>
<div field="MaName" width="100" allowSort="true" >物料名
<input property="editor" class="mini-textbox" style="width:100%;"/>
</div>
<div field="StartQty" width="100" allowSort="true" >期初数量
<input property="editor" class="mini-spinner" style="width:100%;"/>
</div>
<div field="RSDate" width="120" headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss" allowSort="true">创建日期
<input property="editor" class="mini-datepicker" format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" showOkButton="true" showClearButton="false" style="width:100%;" minHeight="50"/>
</div>
<div field="InputQty" width="120" headerAlign="center" allowSort="true">本月入库数量
<input property="editor" class="mini-spinner" style="width:100%;" minHeight="50"/>
</div>
<div field="InputMoney" width="120" headerAlign="center" allowSort="true">本月入库金额
<input property="editor" class="mini-textbox" style="width:100%;" minHeight="50"/>
</div>
<div field="OutputQty" width="120" headerAlign="center" allowSort="true">本月出库数量
<input property="editor" class="mini-spinner" style="width:100%;" minHeight="50"/>
</div>
</div>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid1");
grid.load();
////////////////////////////
function editRow() {
var rows = grid.getSelecteds();
if (rows.length > 0) {
for (var i = 0, l = rows.length; i < l; i++) {
var row = rows;
grid.beginEditRow(row);
}
}
}
function addRow() {
var newRow = { name: "New Row" };
grid.addRow(newRow, 0);
grid.beginEditRow(newRow);
}
function removeRow() {
var rows = grid.getSelecteds();
if (rows.length > 0) {
grid.removeRows(rows, true);
}
}
function saveData() {
grid.commitEdit();
var data = grid.getChanges();
var json = mini.encode(data);
grid.loading("保存中,请稍后......");
$.ajax({
url: "testmodel.aspx?method=SaveEmployees",
data: { data: json },
type: "post",
success: function (text) {
grid.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
}
});
}
////////////////////////
//选择“部门”,设置“职位”
function onDepartChanged(e) {
var combo = e.sender;
var row = grid.getEditorOwnerRow(combo);
var editor = grid.getCellEditor("Position", row);
var id = combo.getValue();
var url = "../demo/data/AjaxService.aspx?method=GetPositionsByDepartmenId&id=" + id
editor.setUrl(url);
editor.setValue("");
}
//“职位”combo的url在cellbeginedit的时候,根据前面值自动设置
grid.on("cellbeginedit", function (e) {
if (e.field == "position") {
var editor = e.editor;
var id = e.record.dept_id;
var url = "../demo/data/AjaxService.aspx?method=GetPositionsByDepartmenId&id=" + id
editor.setUrl(url);
}
});
</script>
|
|