Editable grid question

Editable grid question

SamiSami Posts: 1Questions: 0Answers: 0
edited October 2012 in Plug-ins
Hello,
First of all thank you for the excellent tool. I am new to datatables. I have a requirement where I want to make some rows in the table as editable and some rows read only. I tried setting class as "read_only", but seems like it does not work. Is it that aoColumns needs to be set to 'null' then only the column becomes read only? Here is my code
$('#pm_active_prgms').dataTable({"bJQueryUI":true, bAutoWidth:true, "sScrollX": "300%", "sScrollXInner": "300%", "bScrollCollapse": true,
"oLanguage": {"sZeroRecords": "There are no records that match your search criteria","sSearch": "Filter records:"},
"aoColumns":
[
/* Programs */ {sWidth: '15%'},
/* Status */ {
"fnRender": function ( oObj ) {
var prgmStatus = oObj.aData[1] ;
if (prgmStatus == "ON TRACK" ) {
return 'On track';
}else if (prgmStatus == "MODERATE IMPACT" ) {
return 'No action required, but watch the status';
}else if (prgmStatus == "NEW" ) {
return 'Not yet EC';
}else if (prgmStatus == "CANCELLED" ) {
return 'Cancelled';
}else if (prgmStatus == "COMPLETE" ) {
return 'Complete';
}else if (prgmStatus == "MAJOR IMPACT" ) {
return 'Needs executive focus now';
}else if ( prgmStatus.indexOf("GREEN") >= 0 ) {
return 'On track';
}else if ( prgmStatus.indexOf("YELLOW") >= 0 ) {
return 'No action required, but watch the status';
}else if ( prgmStatus.indexOf("GREY") >= 0 ) {
return 'Not yet EC';
}else if ( prgmStatus.indexOf("BLUE") >= 0 ) {
return 'Complete';
}else if ( prgmStatus.indexOf("RED") >= 0 ) {
return 'Needs executive focus now';
}else{
return 'NA';
}
}
},
/* Last Milestone */ {},
/* Program Type */ {sWidth: '5%'},
/* Engineer Lead */ {sWidth: '10%'},
/* Program manager */ {sWidth: '10%'},
/* Product Manager */ {sWidth: '10%'},
/* CC Actual */ {sWidth: '10%'},
/* EC Actual */ {sWidth: '10%'},
/* FCS Target */ {sWidth: '10%'},
/* FCS Commit */ {sWidth: '10%'},
/* FCS Actual Current */ {sWidth: '10%'}
]
}).makeEditable({ sUpdateURL: "/pcgi-bin/telepresence/ops/pm/pmProgramUpd.pl",
oEditableSettings: { event: 'click' },
"aoColumns": [
/* Programs */ null,
/* Status */ {tooltip: 'Double click to edit Status',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
loadurl: 'perl script',
loadtype: 'GET',
cssclass:"required"
}, /* Last Milestone */ null,
/* Program Type */ {tooltip: 'Double click to edit Program Type',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
loadurl: 'perl script',
loadtype: 'GET',
cssclass:"required"
},
/* Engineer Lead */ {tooltip: 'Double click to edit Engineer Lead', onblur: 'submit'},
/* Program manager */ {tooltip: 'Double click to edit Program Manager', onblur: 'submit'},
/* Product Manager */ {tooltip: 'Double click to edit Product Manager', onblur: 'submit'},
/* CC Actual */ {tooltip: 'Double click to edit CC Actual', onblur: 'submit', cssclass:"date"},
/* EC Actual */ {tooltip: 'Double click to edit EC Actual', onblur: 'submit', cssclass:"date"},
/* FCS Target */ {tooltip: 'Double click to edit FCS Target', onblur: 'submit', cssclass:"date"},
/* FCS Commit */ {tooltip: 'Double click to edit FCS Commit', onblur: 'submit', cssclass:"date"},
/* FCS Actual Current */ {tooltip: 'Double click to edit FCS Actual/Current', onblur: 'submit', cssclass:"date"}
]
});

}

Any pointers will be appreciated. Please provide example if any.
Thanks.
Regards,
Sami

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I don't know you'd you'd do it with makeEditable - but in Editor you'd simply have an `if` condition around the call to the `edit` API method which will check to see if the row is editable or not. I guess something similar can be done in makeEditable. Possibly you'd need to modify the plug-in's source.

    Allan
This discussion has been closed.