关闭对话框后,JQgrid复选框将变为check

时间:2016-08-02 01:14:44

标签: javascript jquery checkbox jqgrid

我在弹出的对话框中为我的JQgrid使用下面的代码。

function LeaveHalfDay() {
    var url1 = URL

    $("#LeaveHalfDayDataEntryList").jqGrid({
        url: url1,
        datatype: 'json',
        mtype: 'POST',
        colNames: ['RowId', 'With Halfday <br /> Morning', 'With Halfday <br /> Afternoon', 'Date', 'Day'],
        colModel: [
                { name: 'rowId', index: 'rowId', hidden: true, editable: true, sortable: false, width: 80, align: 'left' },       
                {name: 'cbox_leave_half', index: 'cbox_leave_half', editable: true, formatter: cboxFormatterLeaveHalfDay, formatoptions: { disabled: false }, edittype: 'checkbox', editoptions: { value: "True:False" }, sortable: false, width: 70, align: 'center' },
                { name: 'cbox_leave_halfPM', index: 'cbox_leave_halfPM', editable: true, formatter: cboxFormatterLeaveHalfDayPM, formatoptions: { disabled: false }, edittype: 'checkbox', editoptions: { value: "True:False" }, sortable: false, width: 70, align: 'center' },
                { name: 'LStartDate', index: 'LStartDate', editable: false, sortable: false, width: 70, align: 'left' },
                { name: 'LDate', index: 'LDate', editable: false, sortable: false, width: 55, align: 'left' }         
          ],
        pager: $('#LeaveHalfDayDataEntryPager'),
        rowNum: 5,
        rowList: [5, 10, 20],
        sortname: '',
        sortorder: '',
        viewrecords: true,
        imgpath: '/Content/themes/redmond/images/',
        height: '100%',           
        loadComplete: function (result, rowid) {
            var ids = jQuery("#LeaveHalfDayDataEntryList").getDataIDs();
            var len = ids.length, newLine;
            if (len < 5) {
                AddNewRowToGrid(len, "#LeaveHalfDayDataEntryList");
            }
            $("#LeaveHalfDayDataEntryPager").css("width", "auto");
            $("#LeaveHalfDayDataEntryPager .ui-paging-info").css("display", "none");
        }
    });
    return false;
}

我有这个picture,例如在我的对话框中关闭我的jqgrid之后。在我的场景中,我只检查日期8/2/2016中的早晨复选框和8/4/2016日期复选框。我尝试重新打开它所有4个复选框都检查。如果这个问题能解决我的另一个问题也会解决,因为它们相互联系。

对于我的jqgrid控制器,这里是我的代码

DateTime _startDate, _endDate, _startCntDate;
        TimeSpan difference;
        _startDate = StartDate;//DateTime.Parse(StartDate);
        _endDate = EndDate;//DateTime.Parse(EndDate);
        _startCntDate = StartDate;//DateTime.Parse(StartDate);
        difference = _endDate - _startDate;
        int i, objCnt = 0;


        for (i = 0; i < (difference.Days + 1); i++)
        {
            if (!(_startCntDate.DayOfWeek == DayOfWeek.Saturday || _startCntDate.DayOfWeek == DayOfWeek.Sunday))
            {
                objCnt++;
            }
            _startCntDate = _startCntDate.AddDays(1);
        }
        var rowsObj = new object[objCnt];
        int rowId = 0;

        for (i = 0; i < (difference.Days + 1); i++)
        {
            if (!(_startDate.DayOfWeek == DayOfWeek.Saturday || _startDate.DayOfWeek == DayOfWeek.Sunday))
            {
                rowsObj[rowId] = new { id = rowId, cell = new object[] { rowId, false, false, _startDate.ToShortDateString(), _startDate.DayOfWeek.ToString() } };
                rowId++;
            }
            _startDate = _startDate.AddDays(1);
        }
        var a = rowsObj.Skip((page - 1) * rows).Take(rows);
        var result = new JsonResult();
        result.Data = new
        {
            totalRecords = rowId,
            total = (int)Math.Ceiling((float)rowsObj.Count() / (float)rows),
            page = page,
            records = a.Count(),
            rows = a
        };
        return result;

0 个答案:

没有答案