65 $.fn.makeEditable =
function (options) {
67 var iDisplayStart = 0;
69 function fnGetCellID(cell) {
79 return properties.fnGetRowID($(cell.parentNode));
82 function _fnSetRowIDInAttribute(row,
id, overwrite) {
97 if (row.attr(
"id") == null || row.attr(
"id") ==
"") {
103 function _fnGetRowIDFromAttribute(row) {
115 return row.attr(
"id");
118 function _fnSetRowIDInFirstCell(row,
id) {
130 $(
"td:first", row).html(
id);
134 function _fnGetRowIDFromFirstCell(row) {
146 return $(
"td:first", row).html();
153 var oAddNewRowButton, oDeleteRowButton, oConfirmRowAddingButton, oCancelRowAddingButton;
160 function _fnShowError(errorText, action) {
170 function _fnStartProcessingMode() {
175 if (oTable.fnSettings().oFeatures.bProcessing) {
176 $(
".dataTables_processing").css(
'visibility',
'visible');
180 function _fnEndProcessingMode() {
186 if (oTable.fnSettings().oFeatures.bProcessing) {
187 $(
".dataTables_processing").css(
'visibility',
'hidden');
191 var sOldValue, sNewCellValue, sNewCellDislayValue;
193 function fnApplyEditable(aoNodes) {
199 if (properties.bDisableEditing) {
202 var oDefaultEditableSettings = {
205 "onsubmit":
function (settings, original) {
206 sOldValue = original.revert;
207 sNewCellValue = null;
208 sNewCellDisplayValue = null;
209 iDisplayStart = fnGetDisplayStart();
211 if(settings.type ==
"text" || settings.type ==
"select" || settings.type ==
"textarea" )
213 var input = $(
"input,select,textarea",
this);
214 sNewCellValue = $(
"input,select,textarea", $(
this)).val();
215 if (input.length == 1) {
216 var oEditElement = input[0];
217 if (oEditElement.nodeName.toLowerCase() ==
"select" || oEditElement.tagName.toLowerCase() ==
"select") {
218 sNewCellDisplayValue = $(
"option:selected", oEditElement).text();
220 sNewCellDisplayValue = sNewCellValue;
224 if (!properties.fnOnEditing(input, settings, original.revert, fnGetCellID(original))) {
230 if (settings.oValidationOptions != null) {
231 input.parents(
"form").validate(settings.oValidationOptions);
233 if (settings.cssclass != null) {
234 input.addClass(settings.cssclass);
236 if(settings.cssclass == null && settings.oValidationOptions == null){
239 if (!input.valid() || 0 == input.valid()) {
248 properties.fnStartProcessingMode();
250 "submitdata":
function (value, settings) {
253 var
id = fnGetCellID(
this);
254 var rowId = oTable.fnGetPosition(
this)[0];
255 var columnPosition = oTable.fnGetPosition(
this)[1];
256 var columnId = oTable.fnGetPosition(
this)[2];
257 var sColumnName = oTable.fnSettings().aoColumns[columnId].sName;
258 if (sColumnName == null || sColumnName ==
"") {
259 sColumnName = oTable.fnSettings().aoColumns[columnId].sTitle;
261 var updateData = null;
262 if (properties.aoColumns == null || properties.aoColumns[columnId] == null) {
263 updateData = $.extend({},
264 properties.oUpdateParameters,
268 "columnPosition": columnPosition,
269 "columnId": columnId,
270 "columnName": sColumnName
274 updateData = $.extend({},
275 properties.oUpdateParameters,
276 properties.aoColumns[columnId].oUpdateParameters,
280 "columnPosition": columnPosition,
281 "columnId": columnId,
282 "columnName": sColumnName
287 "callback":
function (sValue, settings) {
288 properties.fnEndProcessingMode();
290 var aPos = oTable.fnGetPosition(
this);
292 var bRefreshTable = !oSettings.oFeatures.bServerSide;
293 $(
"td.last-updated-cell", oTable.fnGetNodes( )).removeClass(
"last-updated-cell");
294 if(sValue.indexOf(properties.sFailureResponsePrefix)>-1)
296 oTable.fnUpdate(sOldValue, aPos[0], aPos[2], bRefreshTable);
297 $(
"td.last-updated-cell", oTable).removeClass(
"last-updated-cell");
298 $(
this).addClass(
"last-updated-cell");
299 properties.fnShowError(sValue.replace(properties.sFailureResponsePrefix,
"").trim(),
"update");
303 if (properties.sSuccessResponse ==
"IGNORE" ||
304 ( properties.aoColumns != null
305 && properties.aoColumns[aPos[2]] != null
306 && properties.aoColumns[aPos[2]].sSuccessResponse ==
"IGNORE") ||
307 (sNewCellValue == null) || (sNewCellValue == sValue) ||
308 properties.sSuccessResponse == sValue) {
309 if(sNewCellDisplayValue == null)
312 oTable.fnUpdate(sValue, aPos[0], aPos[2], bRefreshTable);
314 oTable.fnUpdate(sNewCellDisplayValue, aPos[0], aPos[2], bRefreshTable);
316 $(
"td.last-updated-cell", oTable).removeClass(
"last-updated-cell");
317 $(
this).addClass(
"last-updated-cell");
320 oTable.fnUpdate(sOldValue, aPos[0], aPos[2], bRefreshTable);
321 properties.fnShowError(sValue,
"update");
326 properties.fnOnEdited(status, sOldValue, sNewCellDisplayValue, aPos[0], aPos[1], aPos[2]);
327 if (settings.fnOnCellUpdated != null) {
328 settings.fnOnCellUpdated(status, sValue, aPos[0], aPos[2], settings);
332 if (properties.bUseKeyTable) {
333 var keys = oTable.keys;
337 setTimeout(
function () { keys.block =
false; }, 0);
340 "onerror":
function () {
341 properties.fnEndProcessingMode();
342 properties.fnShowError(
"Cell cannot be updated",
"update");
343 properties.fnOnEdited(
"failure");
346 "onreset":
function(){
347 if (properties.bUseKeyTable) {
348 var keys = oTable.keys;
352 setTimeout(
function () { keys.block =
false; }, 0);
356 "height": properties.sEditorHeight,
357 "width": properties.sEditorWidth
362 if (properties.aoColumns != null) {
364 for (var iDTindex = 0, iDTEindex = 0; iDTindex < oSettings.aoColumns.length; iDTindex++) {
365 if (oSettings.aoColumns[iDTindex].bVisible) {
366 if (properties.aoColumns[iDTEindex] == null) {
372 cells = $(
"td:nth-child(" + (iDTEindex + 1) +
")", aoNodes);
374 var oColumnSettings = oDefaultEditableSettings;
375 oColumnSettings = $.extend({}, oDefaultEditableSettings, properties.oEditableSettings, properties.aoColumns[iDTEindex]);
377 var sUpdateURL = properties.sUpdateURL;
379 if (oColumnSettings.sUpdateURL != null) {
380 sUpdateURL = oColumnSettings.sUpdateURL;
385 cells.each(
function () {
386 if (!$(
this).hasClass(properties.sReadOnlyCellClass)) {
387 $(this).editable(sUpdateURL, oColumnSettings);
394 cells = $(
'td:not(.' + properties.sReadOnlyCellClass +
')', aoNodes);
395 cells.editable(properties.sUpdateURL, $.extend({}, oDefaultEditableSettings, properties.oEditableSettings));
399 function fnOnRowAdding(event) {
405 if (properties.fnOnAdding()) {
406 if (oAddNewRowForm.valid()) {
407 iDisplayStart = fnGetDisplayStart();
408 properties.fnStartProcessingMode();
410 if (properties.bUseFormsPlugin) {
412 $(oAddNewRowForm).ajaxSubmit({
414 success:
function (
response, statusString, xhr) {
415 if (xhr.responseText.toLowerCase().indexOf(
"error") != -1) {
416 properties.fnEndProcessingMode();
417 properties.fnShowError(xhr.responseText.replace(
"Error",
""),
"add");
418 properties.fnOnAdded(
"failure");
420 fnOnRowAdded(xhr.responseText);
425 properties.fnEndProcessingMode();
426 properties.fnShowError(
response.responseText,
"add");
427 properties.fnOnAdded(
"failure");
434 var params = oAddNewRowForm.serialize();
435 $.ajax({
'url': properties.sAddURL,
437 'type': properties.sAddHttpMethod,
438 'dataType': properties.sAddDataType,
439 success: fnOnRowAdded,
441 properties.fnEndProcessingMode();
442 properties.fnShowError(
response.responseText,
"add");
443 properties.fnOnAdded(
"failure");
449 event.stopPropagation();
450 event.preventDefault();
453 function _fnOnNewRowPosted(data) {
461 function fnOnRowAdded(data) {
468 properties.fnEndProcessingMode();
470 if (properties.fnOnNewRowPosted(data)) {
472 var oSettings = oTable.fnSettings();
473 if (!oSettings.oFeatures.bServerSide) {
474 jQuery.data(oAddNewRowForm,
'DT_RowId', data);
475 var values = fnTakeRowDataFromFormElements(oAddNewRowForm);
480 if (oSettings.aoColumns != null && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
481 rtn = oTable.fnAddData(rowData);
484 rtn = oTable.fnAddData(values);
487 var oTRAdded = oTable.fnGetNodes(rtn);
489 properties.fnSetRowID($(oTRAdded), data,
true);
491 fnApplyEditable(oTRAdded);
493 $(
"tr.last-added-row", oTable).removeClass(
"last-added-row");
494 $(oTRAdded).addClass(
"last-added-row");
499 oAddNewRowForm.dialog(
'close');
500 $(oAddNewRowForm)[0].reset();
501 $(
".error", $(oAddNewRowForm)).html(
"");
504 properties.fnOnAdded(
"success");
505 if (properties.bUseKeyTable) {
506 var keys = oTable.keys;
510 setTimeout(
function () { keys.block =
false; }, 0);
515 function fnOnCancelRowAdding(event) {
523 $(oAddNewRowForm).validate().resetForm();
524 $(oAddNewRowForm)[0].reset();
526 $(
".error", $(oAddNewRowForm)).html(
"");
527 $(
".error", $(oAddNewRowForm)).hide();
530 oAddNewRowForm.dialog(
'close');
531 event.stopPropagation();
532 event.preventDefault();
536 function fnDisableDeleteButton() {
541 if (properties.bUseKeyTable) {
544 if (properties.oDeleteRowButtonOptions != null) {
546 oDeleteRowButton.button(
"option",
"disabled",
true);
548 oDeleteRowButton.attr(
"disabled",
"true");
552 function fnEnableDeleteButton() {
557 if (properties.oDeleteRowButtonOptions != null) {
559 oDeleteRowButton.button(
"option",
"disabled",
false);
561 oDeleteRowButton.removeAttr(
"disabled");
565 var nSelectedRow, nSelectedCell;
566 var oKeyTablePosition;
569 function _fnOnRowDeleteInline(e) {
571 var sURL = $(
this).attr(
"href");
572 if (sURL == null || sURL ==
"") {
573 sURL = properties.sDeleteURL;
579 iDisplayStart = fnGetDisplayStart();
581 nSelectedCell = ($(
this).parents(
'td'))[0];
582 jSelectedRow = ($(
this).parents(
'tr'));
583 nSelectedRow = jSelectedRow[0];
585 jSelectedRow.addClass(properties.sSelectedRowClass);
587 var
id = fnGetCellID(nSelectedCell);
588 if (properties.fnOnDeleting(jSelectedRow,
id, fnDeleteRow)) {
589 fnDeleteRow(
id, sURL);
594 function _fnOnRowDelete(event) {
600 event.preventDefault();
601 event.stopPropagation();
603 iDisplayStart = fnGetDisplayStart();
606 nSelectedCell = null;
608 if (!properties.bUseKeyTable) {
609 if ($(
'tr.' + properties.sSelectedRowClass +
' td', oTable).length == 0) {
611 _fnDisableDeleteButton();
614 nSelectedCell = $(
'tr.' + properties.sSelectedRowClass +
' td', oTable)[0];
616 nSelectedCell = $(
'td.focus', oTable)[0];
619 if (nSelectedCell == null) {
620 fnDisableDeleteButton();
623 if (properties.bUseKeyTable) {
624 oKeyTablePosition = oTable.keys.fnGetCurrentPosition();
626 var
id = fnGetCellID(nSelectedCell);
627 var jSelectedRow = $(nSelectedCell).parent(
"tr");
628 nSelectedRow = jSelectedRow[0];
629 if (properties.fnOnDeleting(jSelectedRow,
id, fnDeleteRow)) {
634 function _fnOnDeleting(tr,
id, fnDeleteRow) {
645 return confirm(
"Are you sure that you want to delete this record?"); ;
649 function fnDeleteRow(
id, sDeleteURL) {
656 var sURL = sDeleteURL;
657 if (sDeleteURL == null) {
658 sURL = properties.sDeleteURL;
660 properties.fnStartProcessingMode();
661 var data = $.extend(properties.oDeleteParameters, {
"id": id });
662 $.ajax({
'url': sURL,
663 'type': properties.sDeleteHttpMethod,
665 "success": fnOnRowDeleted,
666 "dataType": properties.sDeleteDataType,
668 properties.fnEndProcessingMode();
669 properties.fnShowError(
response.responseText,
"delete");
670 properties.fnOnDeleted(
"failure");
684 properties.fnEndProcessingMode();
685 var oTRSelected = nSelectedRow;
694 oTable.fnDeleteRow(oTRSelected);
695 fnDisableDeleteButton();
697 if (properties.bUseKeyTable) {
698 oTable.keys.fnSetPosition( oKeyTablePosition[0], oKeyTablePosition[1] );
700 properties.fnOnDeleted(
"success");
703 properties.fnShowError(
response,
"delete");
704 properties.fnOnDeleted(
"failure");
716 function _fnOnDeleted(result) { }
718 function _fnOnEditing(input) {
return true; }
719 function _fnOnEdited(result, sOldValue, sNewValue, iRowIndex, iColumnIndex, iRealColumnIndex) {
723 function fnOnAdding() {
return true; }
724 function _fnOnAdded(result) { }
727 function fnGetDisplayStart() {
728 return oSettings._iDisplayStart;
731 function fnSetDisplayStart() {
738 oSettings._iDisplayStart = iDisplayStart;
739 oSettings.oApi._fnCalculateEnd(oSettings);
741 oSettings.oApi._fnDraw(oSettings);
745 function _fnOnBeforeAction(sAction) {
749 function _fnOnActionCompleted(sStatus) {
753 function fnGetActionSettings(sAction) {
757 if (properties.aoTableAction) {
758 properties.fnShowError(
"Configuration error - aoTableAction setting are not set", sAction);
762 for (i = 0; i < properties.aoTableActions.length; i++) {
763 if (properties.aoTableActions[i].sAction == sAction) {
764 return properties.aoTableActions[i];
768 properties.fnShowError(
"Cannot find action configuration settings", sAction);
772 function fnPopulateFormWithRowCells(oForm, oTR) {
777 var iRowID = oTable.fnGetPosition(oTR);
779 var
id = properties.fnGetRowID($(oTR));
781 $(oForm).validate().resetForm();
782 jQuery.data($(oForm)[0],
'DT_RowId',
id);
783 $(
"input.DT_RowId", $(oForm)).val(
id);
784 jQuery.data($(oForm)[0],
'ROWID', iRowID);
785 $(
"input.ROWID", $(oForm)).val(iRowID);
788 var oSettings = oTable.fnSettings();
789 var iColumnCount = oSettings.aoColumns.length;
792 $(
"input:text[rel],input:radio[rel][checked],input:hidden[rel],select[rel],textarea[rel],input:checkbox[rel]",
793 $(oForm)).each(
function () {
794 var rel = $(
this).attr(
"rel");
796 if (rel >= iColumnCount) {
797 properties.fnShowError(
"In the form is placed input element with the name '" + $(
this).attr(
"name") +
"' with the 'rel' attribute that must be less than a column count - " + iColumnCount,
"action");
799 var sCellValue = oTable.fnGetData(oTR)[rel];
800 if (this.nodeName.toLowerCase() ==
"select" || this.tagName.toLowerCase() ==
"select") {
802 if (this.multiple ==
true) {
803 var aoSelectedValue =
new Array();
804 aoCellValues = sCellValue.split(
",");
805 for (i = 0; i <= this.options.length - 1; i++) {
806 if (jQuery.inArray(
this.options[i].text.toLowerCase().trim(), aoCellValues) != -1) {
807 aoSelectedValue.push(this.options[i].value);
810 $(
this).val(aoSelectedValue);
812 for (i = 0; i <= this.options.length - 1; i++) {
813 if (this.options[i].text.toLowerCase() == sCellValue.toLowerCase()) {
814 $(
this).val(this.options[i].value);
820 else if (this.nodeName.toLowerCase() ==
"span" || this.tagName.toLowerCase() ==
"span") {
821 $(
this).html(sCellValue);
823 if (this.type ==
"checkbox") {
824 if (sCellValue ==
"true") {
825 $(
this).attr(
"checked",
true);
828 if (this.type ==
"radio") {
829 if (this.value == sCellValue) {
833 this.value = sCellValue;
848 function fnTakeRowDataFromFormElements(oForm) {
854 var iDT_RowId = jQuery.data(oForm,
'DT_RowId');
855 var iColumnCount = oSettings.aoColumns.length;
857 var values =
new Array();
858 var rowData =
new Object();
860 $(
"input:text[rel],input:radio[rel][checked],input:hidden[rel],select[rel],textarea[rel],span.datafield[rel],input:checkbox[rel]", oForm).each(
function () {
861 var rel = $(
this).attr(
"rel");
863 if (rel >= iColumnCount) {
864 properties.fnShowError(
"In the add form is placed input element with the name '" + $(
this).attr(
"name") +
"' with the 'rel' attribute that must be less than a column count - " + iColumnCount,
"add");
866 if (this.nodeName.toLowerCase() ==
"select" || this.tagName.toLowerCase() ==
"select") {
869 $.makeArray($(
"option:selected",
this)),
874 else if (this.nodeName.toLowerCase() ==
"span" || this.tagName.toLowerCase() ==
"span") {
875 sCellValue = $(
this).html();
877 if (this.type ==
"checkbox") {
879 sCellValue = (this.value !=
"on") ? this.value :
"true";
881 sCellValue = (this.value !=
"on") ?
"" :
"false";
884 sCellValue = this.value;
888 sCellValue = sCellValue.replace(
"DATAROWID", iDT_RowId);
889 sCellValue = sCellValue.replace(properties.sIDToken, iDT_RowId);
890 if (oSettings.aoColumns != null
891 && oSettings.aoColumns[rel] != null
892 && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
893 rowData[oSettings.aoColumns[rel].mDataProp] = sCellValue;
895 values[rel] = sCellValue;
900 if (oSettings.aoColumns != null && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
913 function fnSendFormUpdateRequest(nActionForm) {
917 var jActionForm = $(nActionForm);
918 var sAction = jActionForm.attr(
"id");
920 sAction = sAction.replace(
"form",
"");
921 var sActionURL = jActionForm.attr(
"action");
922 if (properties.fnOnBeforeAction(sAction)) {
923 if (jActionForm.valid()) {
924 iDisplayStart = fnGetDisplayStart();
925 properties.fnStartProcessingMode();
926 if (properties.bUseFormsPlugin) {
929 var oAjaxSubmitOptions = {
930 success:
function (
response, statusString, xhr) {
931 properties.fnEndProcessingMode();
932 if (
response.toLowerCase().indexOf(
"error") != -1 || statusString !=
"success") {
933 properties.fnShowError(
response, sAction);
934 properties.fnOnActionCompleted(
"failure");
936 fnUpdateRowOnSuccess(nActionForm);
937 properties.fnOnActionCompleted(
"success");
942 properties.fnEndProcessingMode();
943 properties.fnShowError(
response.responseText, sAction);
944 properties.fnOnActionCompleted(
"failure");
947 var oActionSettings = fnGetActionSettings(sAction);
948 oAjaxSubmitOptions = $.extend({}, properties.oAjaxSubmitOptions, oAjaxSubmitOptions);
949 $(oActionForm).ajaxSubmit(oAjaxSubmitOptions);
952 var params = jActionForm.serialize();
953 $.ajax({
'url': sActionURL,
955 'type': properties.sAddHttpMethod,
956 'dataType': properties.sAddDataType,
958 properties.fnEndProcessingMode();
959 fnUpdateRowOnSuccess(nActionForm);
960 properties.fnOnActionCompleted(
"success");
963 properties.fnEndProcessingMode();
964 properties.fnShowError(
response.responseText, sAction);
965 properties.fnOnActionCompleted(
"failure");
973 function fnUpdateRowOnSuccess(nActionForm) {
977 var values = fnTakeRowDataFromFormElements(nActionForm);
979 var iRowID = jQuery.data(nActionForm,
'ROWID');
980 var oSettings = oTable.fnSettings();
981 var iColumnCount = oSettings.aoColumns.length;
982 for (var rel = 0; rel < iColumnCount; rel++) {
983 if (oSettings.aoColumns != null
984 && oSettings.aoColumns[rel] != null
985 && isNaN(parseInt(oSettings.aoColumns[0].mDataProp))) {
986 sCellValue = rowData[oSettings.aoColumns[rel].mDataProp];
988 sCellValue = values[rel];
990 if (sCellValue != undefined) {
991 oTable.fnUpdate(sCellValue, iRowID, rel);
996 $(nActionForm).dialog(
'close');
1006 sUpdateURL:
"UpdateData",
1008 sDeleteURL:
"DeleteData",
1009 sAddNewRowFormId:
"formAddNewRow",
1010 oAddNewRowFormOptions: { autoOpen:
false, modal:
true },
1011 sAddNewRowButtonId:
"btnAddNewRow",
1012 oAddNewRowButtonOptions: null,
1013 sAddNewRowOkButtonId:
"btnAddNewRowOk",
1014 sAddNewRowCancelButtonId:
"btnAddNewRowCancel",
1015 oAddNewRowOkButtonOptions: { label:
"Ok" },
1016 oAddNewRowCancelButtonOptions: { label:
"Cancel" },
1017 sDeleteRowButtonId:
"btnDeleteRow",
1018 oDeleteRowButtonOptions: null,
1019 sSelectedRowClass:
"row_selected",
1020 sReadOnlyCellClass:
"read_only",
1021 sAddDeleteToolbarSelector:
".add_delete_toolbar",
1022 fnShowError: _fnShowError,
1023 fnStartProcessingMode: _fnStartProcessingMode,
1024 fnEndProcessingMode: _fnEndProcessingMode,
1026 fnOnDeleting: _fnOnDeleting,
1027 fnOnDeleted: _fnOnDeleted,
1028 fnOnAdding: fnOnAdding,
1029 fnOnNewRowPosted: _fnOnNewRowPosted,
1030 fnOnAdded: _fnOnAdded,
1031 fnOnEditing: _fnOnEditing,
1032 fnOnEdited: _fnOnEdited,
1033 sAddHttpMethod:
'POST',
1034 sAddDataType:
"text",
1035 sDeleteHttpMethod:
'POST',
1036 sDeleteDataType:
"text",
1037 fnGetRowID: _fnGetRowIDFromAttribute,
1038 fnSetRowID: _fnSetRowIDInAttribute,
1039 sEditorHeight:
"100%",
1040 sEditorWidth:
"100%",
1041 bDisableEditing:
false,
1042 oDeleteParameters: {},
1043 oUpdateParameters: {},
1044 sIDToken:
"DT_RowId",
1045 aoTableActions: null,
1046 fnOnBeforeAction: _fnOnBeforeAction,
1047 bUseFormsPlugin:
false,
1048 fnOnActionCompleted: _fnOnActionCompleted,
1049 sSuccessResponse:
"ok",
1050 sFailureResponsePrefix:
"ERROR",
1055 properties = $.extend(defaults, options);
1056 oSettings = oTable.fnSettings();
1057 properties.bUseKeyTable = (properties.oKeyTable != null);
1059 return this.each(
function () {
1060 var sTableId = oTable.dataTableSettings[0].sTableId;
1062 if (properties.bUseKeyTable) {
1063 var keys = new KeyTable({
1064 "table": document.getElementById(sTableId),
1070 keys.event.action(null, null,
function (nCell) {
1071 if( $(nCell).hasClass(properties.sReadOnlyCellClass)) {
1077 setTimeout(
function () { $(nCell).dblclick(); }, 0);
1089 if (oTable.fnSettings().sAjaxSource != null) {
1090 oTable.fnSettings().aoDrawCallback.push({
1093 fnApplyEditable(oTable.fnGetNodes());
1094 $(oTable.fnGetNodes()).each(
function () {
1095 var position = oTable.fnGetPosition(
this);
1096 var
id = oTable.fnGetData(position)[0];
1097 properties.fnSetRowID($(
this),
id);
1101 "sName":
"fnApplyEditable" 1106 fnApplyEditable(oTable.fnGetNodes());
1110 oAddNewRowForm = $(
"#" + properties.sAddNewRowFormId);
1111 if (oAddNewRowForm.length != 0) {
1114 var oSettings = oTable.fnSettings();
1115 var iColumnCount = oSettings.aoColumns.length;
1116 for (i = 0; i < iColumnCount; i++) {
1117 if ($(
"[rel=" + i +
"]", oAddNewRowForm).length == 0) {
1118 properties.fnShowError(
"In the form that is used for adding new records cannot be found an input element with rel=" + i +
" that will be bound to the value in the column " + i +
". See http://code.google.com/p/jquery-datatables-editable/wiki/AddingNewRecords#Add_new_record_form for more details",
"init");
1123 if (properties.oAddNewRowFormOptions != null) {
1124 properties.oAddNewRowFormOptions.autoOpen =
false;
1126 properties.oAddNewRowFormOptions = { autoOpen:
false };
1128 oAddNewRowForm.dialog(properties.oAddNewRowFormOptions);
1131 oAddNewRowButton = $(
"#" + properties.sAddNewRowButtonId);
1132 if (oAddNewRowButton.length != 0) {
1134 if(oAddNewRowButton.data(
"add-event-attached")!=
"true")
1136 oAddNewRowButton.click(
function () {
1137 oAddNewRowForm.dialog(
'open');
1139 oAddNewRowButton.data(
"add-event-attached",
"true");
1143 if ($(properties.sAddDeleteToolbarSelector).length == 0) {
1144 throw "Cannot find a button with an id '" + properties.sAddNewRowButtonId +
"', or placeholder with an id '" + properties.sAddDeleteToolbarSelector +
"' that should be used for adding new row although form for adding new record is specified";
1146 oAddNewRowButton = null;
1151 if (oAddNewRowForm[0].nodeName.toLowerCase() ==
"form") {
1152 oAddNewRowForm.unbind(
'submit');
1153 oAddNewRowForm.submit(
function (event) {
1154 fnOnRowAdding(event);
1158 $(
"form", oAddNewRowForm[0]).unbind(
'submit');
1159 $(
"form", oAddNewRowForm[0]).submit(
function (event) {
1160 fnOnRowAdding(event);
1166 var aAddNewRowFormButtons = [];
1168 oConfirmRowAddingButton = $(
"#" + properties.sAddNewRowOkButtonId, oAddNewRowForm);
1169 if (oConfirmRowAddingButton.length == 0) {
1171 if (properties.oAddNewRowOkButtonOptions.text == null
1172 || properties.oAddNewRowOkButtonOptions.text ==
"") {
1173 properties.oAddNewRowOkButtonOptions.text =
"Ok";
1175 properties.oAddNewRowOkButtonOptions.click = fnOnRowAdding;
1176 properties.oAddNewRowOkButtonOptions.id = properties.sAddNewRowOkButtonId;
1178 aAddNewRowFormButtons.push(properties.oAddNewRowOkButtonOptions);
1180 oConfirmRowAddingButton.click(fnOnRowAdding);
1183 oCancelRowAddingButton = $(
"#" + properties.sAddNewRowCancelButtonId);
1184 if (oCancelRowAddingButton.length == 0) {
1186 if (properties.oAddNewRowCancelButtonOptions.text == null
1187 || properties.oAddNewRowCancelButtonOptions.text ==
"") {
1188 properties.oAddNewRowCancelButtonOptions.text =
"Cancel";
1190 properties.oAddNewRowCancelButtonOptions.click = fnOnCancelRowAdding;
1191 properties.oAddNewRowCancelButtonOptions.id = properties.sAddNewRowCancelButtonId;
1193 aAddNewRowFormButtons.push(properties.oAddNewRowCancelButtonOptions);
1195 oCancelRowAddingButton.click(fnOnCancelRowAdding);
1198 if (aAddNewRowFormButtons.length > 0) {
1199 oAddNewRowForm.dialog(
'option',
'buttons', aAddNewRowFormButtons);
1204 oConfirmRowAddingButton = $(
"#" + properties.sAddNewRowOkButtonId);
1205 oCancelRowAddingButton = $(
"#" + properties.sAddNewRowCancelButtonId);
1207 if (properties.oAddNewRowFormValidation != null) {
1208 oAddNewRowForm.validate(properties.oAddNewRowFormValidation);
1211 oAddNewRowForm = null;
1215 oDeleteRowButton = $(
'#' + properties.sDeleteRowButtonId);
1216 if (oDeleteRowButton.length != 0)
1218 if(oDeleteRowButton.data(
"delete-event-attached")!=
"true")
1220 oDeleteRowButton.click(_fnOnRowDelete);
1221 oDeleteRowButton.data(
"delete-event-attached",
"true");
1225 oDeleteRowButton = null;
1230 oAddDeleteToolbar = $(properties.sAddDeleteToolbarSelector);
1231 if (oAddDeleteToolbar.length != 0) {
1232 if (oAddNewRowButton == null && properties.sAddNewRowButtonId !=
"" 1233 && oAddNewRowForm != null) {
1234 oAddDeleteToolbar.append(
"<button id='" + properties.sAddNewRowButtonId +
"' class='add_row'>Add</button>");
1235 oAddNewRowButton = $(
"#" + properties.sAddNewRowButtonId);
1236 oAddNewRowButton.click(
function () { oAddNewRowForm.dialog(
'open'); });
1238 if (oDeleteRowButton == null && properties.sDeleteRowButtonId !=
"") {
1239 oAddDeleteToolbar.append(
"<button id='" + properties.sDeleteRowButtonId +
"' class='delete_row'>Delete</button>");
1240 oDeleteRowButton = $(
"#" + properties.sDeleteRowButtonId);
1241 oDeleteRowButton.click(_fnOnRowDelete);
1246 if (oDeleteRowButton != null) {
1247 if (properties.oDeleteRowButtonOptions != null) {
1248 oDeleteRowButton.button(properties.oDeleteRowButtonOptions);
1250 fnDisableDeleteButton();
1254 if (oAddNewRowButton != null) {
1255 if (properties.oAddNewRowButtonOptions != null) {
1256 oAddNewRowButton.button(properties.oAddNewRowButtonOptions);
1262 if (oConfirmRowAddingButton != null) {
1263 if (properties.oAddNewRowOkButtonOptions != null) {
1264 oConfirmRowAddingButton.button(properties.oAddNewRowOkButtonOptions);
1269 if (oCancelRowAddingButton != null) {
1270 if (properties.oAddNewRowCancelButtonOptions != null) {
1271 oCancelRowAddingButton.button(properties.oAddNewRowCancelButtonOptions);
1281 $(oTable).on(
"click",
'.table-action-deletelink', _fnOnRowDeleteInline);
1283 if (!properties.bUseKeyTable) {
1286 $(
"tbody", oTable).click(
function (event) {
1287 if ($(event.target.parentNode).hasClass(properties.sSelectedRowClass)) {
1288 $(
event.target.parentNode).removeClass(properties.sSelectedRowClass);
1289 if (oDeleteRowButton != null) {
1290 fnDisableDeleteButton();
1293 $(oTable.fnSettings().aoData).each(
function () {
1294 $(this.nTr).removeClass(properties.sSelectedRowClass);
1296 $(
event.target.parentNode).addClass(properties.sSelectedRowClass);
1297 if (oDeleteRowButton != null) {
1298 fnEnableDeleteButton();
1303 oTable.keys.event.focus(null, null,
function (nNode, x, y) {
1308 if (properties.aoTableActions != null) {
1309 for (var i = 0; i < properties.aoTableActions.length; i++) {
1310 var oTableAction = $.extend({ sType:
"edit" }, properties.aoTableActions[i]);
1311 var sAction = oTableAction.sAction;
1312 var sActionFormId = oTableAction.sActionFormId;
1314 var oActionForm = $(
"#form" + sAction);
1315 if (oActionForm.length != 0) {
1316 var oFormOptions = { autoOpen:
false, modal:
true };
1317 oFormOptions = $.extend({}, oTableAction.oFormOptions, oFormOptions);
1318 oActionForm.dialog(oFormOptions);
1319 oActionForm.data(
"action-options", oTableAction);
1321 var oActionFormLink = $(
".table-action-" + sAction);
1322 if (oActionFormLink.length != 0) {
1329 oActionFormLink.on(
"click",
function () {
1332 var sClass = this.className;
1333 var classList = sClass.split(/\
s+/);
1334 var sActionFormId =
"";
1336 for (i = 0; i < classList.length; i++) {
1337 if (classList[i].indexOf(
"table-action-") > -1) {
1338 sAction = classList[i].replace(
"table-action-",
"");
1339 sActionFormId =
"#form" + sAction;
1342 if (sActionFormId ==
"") {
1343 properties.fnShowError(
"Cannot find a form with an id " + sActionFormId +
" that should be associated to the action - " + sAction, sAction)
1346 var oTableAction = $(sActionFormId).data(
"action-options");
1348 if (oTableAction.sType ==
"edit") {
1351 var oTR = ($(
this).parents(
'tr'))[0];
1352 fnPopulateFormWithRowCells(oActionForm, oTR);
1354 $(oActionForm).dialog(
'open');
1358 oActionForm.submit(
function (event) {
1360 fnSendFormUpdateRequest(
this);
1366 var aActionFormButtons =
new Array();
1370 var oActionFormCancel = $(
"#form" + sAction +
"Cancel", oActionForm);
1371 if (oActionFormCancel.length != 0) {
1372 aActionFormButtons.push(oActionFormCancel);
1373 oActionFormCancel.click(
function () {
1375 var oActionForm = $(
this).parents(
"form")[0];
1377 $(oActionForm).validate().resetForm();
1378 $(oActionForm)[0].reset();
1380 $(
".error", $(oActionForm)).html(
"");
1381 $(
".error", $(oActionForm)).hide();
1382 $(oActionForm).dialog(
'close');
1387 $(
"button", oActionForm).button();
int s
The socket that the CLI will use to communicate.
int response
Is a response expected from the scheduler.