lundi 1 août 2016

JQgrid checkboxes becomes check after closing a dialog box

I'm using this code below for my JQgrid inside a pop-up dialog box.

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;
}

I have this picture as for example after closing my jqgrid inside my dialog box. At my scenario I only check the morning checkbox in dated 8/2/2016 and afternoon checkbox in dated 8/4/2016. And I try to reopen it all 4 check boxes are check. If ever this problem will solve my another problem also will be solve because they link to each other.

And for my controller for my jqgrid here is my code

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;




Aucun commentaire:

Enregistrer un commentaire