jQuery MiniUI

 找回密码
 立即注册
查看: 3457|回复: 7
打印 上一主题 下一主题

获取当前行时会出错怎么办 [复制链接]

Rank: 2

跳转到指定楼层
楼主
发表于 2015-11-24 17:08:55 |只看该作者 |倒序浏览
想实现一个实时更新时间差的功能,修改完date里面数据就获得当前修改完的行的数据。
但是有时会获得不了当前行,使用的是单元格编辑,编辑完当前行又没选上,这个该怎么办?

function changedate(e) {

    var rows = Grid2.getSelected();//获取当前行
    if (rows == null)  //有时会选不上
        return;
    var startdate = getDate(rows.BeginDate);//转化日期格式
    var enddate = getDate(rows.SubDate);//转化日期格式
    rows.WorkDay = DateDiff(startdate, enddate);//修改数据内容
    Grid2.commitEdit();//提交编辑的数据
}


Rank: 8Rank: 8

沙发
发表于 2015-11-24 17:28:19 |只看该作者
你是在什么事件里处理的

Rank: 2

板凳
发表于 2015-11-25 08:20:48 |只看该作者
function LoadeGrid2(recordId) {
    Grid2.set({
        url: Url,
        style: "width:100%;height:" + ($(document).height() - 68) * 0.5 + "px",
        allowAlternating: true,
        allowUnselect: true,
        multiSelect: true,
        pageSize: 10,
        idField: "id",
        ondrawsummarycell: "onDrawSummaryCell",
        showSummaryRow: "true",
        allowResize: "true",
        allowCellEdit: "true",
        allowCellSelect:"true",
        columns: [
            { type: "checkcolumn", width: "30px" },
            { header: "客户平台问题号", field: "PlatformID", width: "100px", align: "center", headerAlign: "center", editor: { type: "textbox", width: "100%"} },
            { header: "月份", field: "MontInfo", width: "100px", align: "center", headerAlign: "center", dateFormat: "yyyy-MM-dd", editor: { type: "datepicker",  width: "100%"} },
            { header: "系统名称", field: "SysID", displayField: "SysName", width: "80px", align: "center", headerAlign: "center", editor: { type: "combobox", id: "SysName", showNullItem: "true", onbeforeshowpopup: SetSysNameData, width: "100%"} },
            { header: "项目经理", field: "ProjectManagerID", displayField: "ProjectManager", width: "80px", align: "center", headerAlign: "center", editor: { type: "combobox", id: "ProjectManager", onbeforeshowpopup: SetProjectManagerData, showNullItem: "true", width: "100%"} },
            { header: "开始开发时间", field: "BeginDate", width: "100px", align: "center", headerAlign: "center", dateFormat: "yyyy-MM-dd", editor: { type: "datepicker", width: "100%", onvaluechanged: changedate} },
            { header: "提交发布时间", field: "SubDate", width: "100px", align: "center", headerAlign: "center", dateFormat: "yyyy-MM-dd",  editor: { type: "datepicker", width: "100%", onvaluechanged: changedate} },
            { header: "开发工作量", field: "WorkDay", width: "80px", align: "center", headerAlign: "center", editor: { type: "textbox", vtype:"int", width: "100%"} },
            { header: "应发金额", field: "SumMoney", numberFormat: "¥#,0.00", width: "80px", align: "center", headerAlign: "center", editor: { type: "textbox", width: "100%"} },
            { header: "评估工作量", field: "EvaluationDay", width: "80px", align: "center", headerAlign: "center", editor: { type: "textbox", vtype: "int", width: "100%"} },
            { header: "延迟工作量", field: "DelayDay", width: "80px", align: "center", headerAlign: "center", editor: { type: "textbox", vtype: "int", width: "100%"} },
            { header: "备注", field: "Remark", width: "250px", align: "center", headerAlign: "center", editor: { type: "textbox", width: "100%"} }
        ]
    });
    Grid2.render($("#detailGrid_Form")[0]);
    Grid2.load({ method: "GetReportDetailList", RecordID: recordId });
}//生成方法

Rank: 2

地板
发表于 2015-11-25 08:23:00 |只看该作者
dforce 发表于 2015-11-24 17:28
你是在什么事件里处理的

想通过点击修改获得当前行,但是传入e只能获得当前单元格,能不能通过e获得的uid取到当前行?

Rank: 8Rank: 8

5#
发表于 2015-11-25 09:20:52 |只看该作者
zhou259358 发表于 2015-11-25 08:23
想通过点击修改获得当前行,但是传入e只能获得当前单元格,能不能通过e获得的uid取到当前行? ...

var editor=e.sender
var row=grid.getEditorOwnerRow(editor)

Rank: 2

6#
发表于 2015-11-25 09:51:33 |只看该作者
felt 发表于 2015-11-25 09:20
var editor=e.sender
var row=grid.getEditorOwnerRow(editor)

可以了,谢谢

Rank: 2

7#
发表于 2015-11-25 11:34:37 |只看该作者
felt 发表于 2015-11-25 09:20
var editor=e.sender
var row=grid.getEditorOwnerRow(editor)

发现了新问题,在之前的js中row.WorkDay =“”;这样子修改的只是input里面的值,外面显示的不是最新的值如上图,修改完时间,然后更新工作量发生了input文本框里修改了而显示没有修改的情况。有没有能更新外面文本的方法?
附件: 你需要登录才可以下载或查看附件。没有帐号?立即注册

Rank: 8Rank: 8

8#
发表于 2015-11-25 12:07:15 |只看该作者
本帖最后由 dforce 于 2015-11-26 09:27 编辑
zhou259358 发表于 2015-11-25 11:34
发现了新问题,在之前的js中row.WorkDay =“”;这样子修改的只是input里面的值,外面显示的不是最新的值 ...

grid.updateRow(row,{field:value})
这样才是更新数据

Archiver|普加软件

GMT+8, 2024-9-29 11:33 , Processed in 1.043203 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部