[RESOLVED]Need only some rows to readonly in jqgrid based on date column

HI,

We are using jqgrid, and asp.net, In jqgrid the data will populate as like below.

id description date
Eg:
34 ‘present’ 2014/10/13

The description column has edit options like dropdown ,now based on date column as per i mentioned  below next week data rows should be read only…

and the current week should be editable….

I have a date column where the data is loaded every wednesday night,like next 2 weeks data.

For eg: today is 13 monday,the week starts from sunday to saturday.

In my database now the date column has the data until 10/25.so till 10/18 the records should be editable

from 10/19 to 10/26 should be in read mode.

The idea is that next week data 10/19 to 10/25 will be loaded again on wednesday in order to avoid overwritten the records in database.we are able to edit only current week records.

This is my aspx code

 

$("#list").jqGrid({

url:——-

datatype:‘json’,

height: 250,

colNames: [

‘ID’,
‘ Description’,
‘ Date’],

colModel: [

{ name:

‘ID’,
index:
‘ID’, width: 256, stype:
‘text’, editable:
true, sortable:
false, editoptions: { disabled:
"disabled"} },

{ name:

‘Desc’,
index:
‘Desc’, width: 256, stype:
‘text’, sortable:
false, editable:
true, edittype:
‘select’,editoptions: {readonly:
true},

formatter: rowColorFormatter,

editoptions: { value:

"present:present; unpresent:unpresent"
}},

{ name:

‘Date’,
index:
‘lDate’, width: 256, editable:
true, stype:
‘text’, sortable:
true, sorttype:
‘date’, editoptions: { disabled:
"disabled"} }

 

How can i do the date manipulation in frontend ( need to find the start date for this week and the start date for next week and only allow rows where the date is >= the start date
for this week and < the start date for next week. )

Hi mcfarlandparkway,

For your issue is related jqgrid belong to the third party  library which is out of our support scope,i suggest that you can post your issue to their forum for a professional suggestion:
http://www.trirand.com/blog/?page_id=393

And here are my suggestion which may give you a right direction:

You can find the start date for this week and the start date for next week,then custom formatter your special column following the documentation by the link below:L

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter

Best Regards,

Kevin Shen.

Hi kevin,

         This is what i added the code for making some rows to read only,still not hitting ..not sure where i am doing the mistake.will you plz take a look.I have declared the variable for start date and added the logic in onselect row event,all i need is
Desc column should be in read mode based on date logic…

var
today =
new Date();

var startDay = 0;

var weekStart =
new Date(today.getDate() – (7 + today.getDay() – startDay)
% 7);

$("#list").jqGrid({

url:——-

datatype:‘json’,

height: 250,

colNames: [‘ID’,
‘ Description’,
‘ Date’],

colModel: [{ name:‘ID’,
index:
‘ID’, width: 256, stype:
‘text’, editable:
true, sortable:
false, editoptions: { disabled:
"disabled"} },

{ name:‘Desc’, index:
‘Desc’, width: 256, stype:
‘text’, sortable:
false, editable:
true, edittype:
‘select’,editoptions: {readonly:
true},
formatter: rowColorFormatter,

editoptions: { value:"present:present; unpresent:unpresent"
}},

{ name:‘Date’, index:
‘lDate’, width: 256, editable:
true, stype:
‘text’, sortable:
true, sorttype:
‘date’, editoptions: { disabled:
"disabled"} }

onSelectRow:function(id)
{

if
(id && id !== lastSelectedId) {

$(

‘#list’).restoreRow(lastSelectedId);

$(

‘#list’).editRow(id,
true);

lastSelectedId = id;

}

var
grid = $(
‘#list’);

var
rowids = grid.getDataIDs();

var
columnModels = grid.getGridParam().colModel;

//
check each visible row

for
(
var i = 0; i < rowids.length; i++) {

var
rowid = rowids[i];

var
data = grid.getRowData(rowid);

if
(data.CalDate >= weekStart) {
// view only

//
check each column

for
(
var j = 0; j < columnModels.length; j++) {

var
model = columnModels[j];

if
(model.editable) {

grid.setCell(rowid, model.EventDesc,,
‘not-editable-cell’, { editable:
false });

}

}

}

}

},

Hi mcfarlandparkway,

For your issue is related jqgrid belong to the third party  library which is out of our support scope,

i suggest that you can post your issue to their forum for a professional suggestion:

http://www.trirand.com/blog/?page_id=393

Best Regards,

Kevin Shen.

Leave a Reply