Hello sir/mam,
I have created a custom editor. It works on the value of a checkbox and that checkbox is only visible on edit/add row. When that checkbox is checked it should display a dropdown else textbox. When I am checking the checkbox and I am selecting the value of custom editor combo its showing error valuechanged is not defined.Also, sometimes its giving error this.editor.destrory is not defined/ not a function. The last issue is when clicking on add the location of action dropdown is giving validation as soon as i click on edit row which shouldnt happend unless save is clicked. Could you please help me out.
Code:--
function getGridColumnSettings() {return [{columnKey: "action_id",readOnly: false,required: true,editorProvider: new $.ig.EditorProviderComboTextbox()},{columnKey: "Delivered",editorType: "checkbox",editorOptions: {valueChanging: function (evt, ui) {const checkbox = ui.newValueconst combo = $("#combo")const txtEditor = $("#textEditor")// Reset both editors to defaultconst resetEditors = () => {combo.igCombo("value", "0");txtEditor.igTextEditor("value", "");};resetEditors();if (checkbox) {txtEditor.hide()combo.show()editorProvider.currentEditor = combo} else {txtEditor.show()combo.hide()editorProvider.currentEditor = txtEditor}}}},}--custom editor
var rowIDvar editorProvider$.ig.EditorProviderComboTextbox = $.ig.EditorProvider.extend({createEditor: function (callbacks,key,editorOptions,tabIndex,format,element,) {element = $("<div id='templateContainer'></div>")element.append('<div id="textEditor"></div>')element.append('<div id="combo"></div>')this._super(callbacks, key, editorOptions, tabIndex, format, element)
element.on("keydown", $.proxy(this.keyDown, this))
this.editor = {}this.editor.element = element
return element},getValue: function () {if (this.currentEditor.attr("id") == "textEditor")return this.currentEditor.igTextEditor("value")else return this.currentEditor.igCombo("value")},setValue: function (val) {let checkbox = falsedebugger;if (rowID) {checkbox = $("#master_grid").igGrid("getCellValue", rowID, "Delivered")}
this.combo = $("#combo")this.txtEditor = $("#textEditor")if (checkbox) {this.txtEditor.hide()this.combo.show()this.currentEditor = this.combo} else {this.txtEditor.show()this.combo.hide()this.currentEditor = this.txtEditor}editorProvider = this
createControls(val)},setSize: function (width, height) {this.editor.element.css({width: width,height: height,})},keyDown: function (evt) {var ui = {}ui.owner = this.editor.elementui.owner.element = this.editor.elementthis.callbacks.keyDown(evt, ui, this.columnKey)this.callbacks.textChanged(evt, ui, this.columnKey)},})/*** @author Rohit Rawat* @description This function is used to created combo and text editor.*/function createControls(val) {$("#combo").igCombo({allowCustomValues: false,dataSource: data_ddl.actions,textKey: "name",valueKey: "code",mode: "dropdown",visibleItemsCount: 5,width: "100%",height: "100%",selectionChanged: function (evt, ui) {var ui = {}ui.owner = editorProvider.editor.elementui.owner.element = editorProvider.editor.elementeditorProvider.callbacks.valueChanged(evt, ui, editorProvider.columnKey)},})$("#combo").igCombo("value", val)
$("#textEditor").igTextEditor({width: "100%",placeHolder: "Enter Text",value: val,height: "100%",})}
I have two svg on click of which i enable edit/delete:-
//enable editing via click of svg.grid.on("click", ".edit-icon", function () {// toggleStandardCheckbox(true);const rowId = $(this).data("id");if (!rowId) return;
// Allow edit just for this actionwindow.allowEditFromIcon = true;
// Cancel any ongoing editgrid.igGridUpdating("endEdit", true);
// Show the Delivered column manually, then start edit$("#master_grid").igGrid("showColumn", "Delivered", function () { // to hide and show columngrid.igGridUpdating("startEdit", rowId);});// Reset the flag right after so normal clicks are blocked againsetTimeout(() => {window.allowEditFromIcon = false; // to prevent editing via double click.}, 100);});//This event is created to give user a popup when user clicks on delete row icon.If user clicks yes the row will be deleted.$("#master_grid").on("click", ".delete-icon", function () {grid.igGridUpdating("endEdit");const rowId = $(this).data("id");//fetching id of current row
if (!rowId) {return;}
// Show a confirmation dialog to the userfnShowCommonPopup('confirm', "Are you sure you want to delete this row?", resource_val.Confirmation, function () {// Call the deleteRowAndCleanUp function after user confirmsdeleteRowAndCleanUp(rowId);}, function () { grid.igGridUpdating("endEdit"); }); //to disable edit when user clicks on no.
});
This is the column which is giving validation automatically when add row is clicked:--
{columnKey: "location_of_action_id",editorType: "combo",required: true,editorOptions: {dataSource: [{ code: "", name: "Select Location Of Action" }].concat(data_ddl.location_of_action),textKey: "name",valueKey: "code",mode: "dropdown",visibleItemsCount: 5,allowTooltips: true,selectionChanged: function (evt, ui) {const combo = ui.owner;const selectedItem = ui.items[0];
const newValue = selectedItem ? selectedItem.data.code : "";
const rowId = combo.element.closest("tr[data-id]").attr("data-id");if (!rowId) return;
if (!pendingVersionUpdate[rowId]) {const rowData = $("#master_grid").igGrid("findRecordByKey", rowId) || {};pendingVersionUpdate[rowId] = { ...rowData };}
pendingVersionUpdate[rowId].location_of_action_id = newValue;
const action = pendingVersionUpdate[rowId].action_id || "";const location = newValue;
if (checkIfDuplicateExists(location, action, rowId)) {fnShowCommonPopup('error', "This combination already exists.", "Duplicate Entry");combo.value(""); // Reset the combo}}}},
This is my updating feature:--
{name: "Updating",enableAddRow: true,enableDeleteRow: false,showDoneCancelButtons: true,editMode: "row",doneLabel: "Save",columnSettings: getGridColumnSettings(),editRowStarted: function (evt, ui) {$("#master_grid_updating_cancel").off("click").on("click", function () {$("#master_grid").igGrid("hideColumn", "Delivered");});
$("#master_grid_updating_done").off("click").on("click", function () {$("#master_grid").igGrid("hideColumn", "Delivered");});},editRowEnding: function (evt, ui) {if (editStarting) {$("#master_grid").igGridUpdating("endEdit")editStarting = falsereturn false}},editRowStarting: function (evt, ui) {if (!window.allowEditFromIcon && ui.rowAdding == false) {evt.preventDefault();}rowID = ui.rowIDeditStarting = true$("#master_grid").igGrid("showColumn", "Delivered", function () {$("#master_grid").igGridUpdating("endEdit")if (ui.rowID) {$("#master_grid").igGridUpdating("startEdit", ui.rowID, 0)} else {$("#master_grid").igGridUpdating("startAddRowEdit")}})},editCellStarting: function (evt, ui) {// Block edit unless it's triggered via the iconif (!window.allowEditFromIcon && ui.rowAdding == false) {evt.preventDefault();}},// Handling when the cell edit is endingeditCellEnding: function (evt, ui) {// toggleStandardCheckbox();// toggleStandardCheckbox(true);let rowId = ui.rowID;
// If it's a new row (rowId is null), generate a temporary unique rowIdif (!rowId) {rowId = `new_row_${Date.now()}`; // Create a unique temporary rowId using timestamp}
// If no entry exists for this rowId, copy the current row data or create a new entryif (!pendingVersionUpdate[rowId]) {const rowData = $("#master_grid").igGrid("findRecordByKey", rowId) || {}; // Fallback to empty object if new rowpendingVersionUpdate[rowId] = { ...rowData }; // Create a shallow copy of row data}
// Save the in-progress edit for this rowpendingVersionUpdate[rowId][ui.columnKey] = ui.value ?? "";},
// Handling when the cell edit is completededitCellEnded: function (evt, ui) {let rowId = ui.rowID;// If it's a new row (rowId is null), use the generated temporary rowIdif (!rowId) {rowId = `new_row_${Date.now()}`;}
// If no entry exists for this rowId, return (exit)if (!pendingVersionUpdate[rowId]) return;
const updatedRow = pendingVersionUpdate[rowId];const location = updatedRow.location_of_action_id || "";const action = updatedRow.action_id || "";// Get the location and action values from the edited row
if (location && action) {const version = generateVersion(location, action);
// Safely update version_no after the grid commits the cell$("#master_grid").igGridUpdating("updateRow", rowId, {version_no: version});}
// Clear the temporary storage for this row (remove from pending updates)delete pendingVersionUpdate[rowId];},Please help me with issue.
The auto validation issue is because i m calling end edit it in editRowStarting . If i dont call it its giving eror grid is already in edit mode.
And the other issue this.editor.destory and valuechanged is undefined i cannot fine why its coming.
Hello,
Thank you for the sample.
I noticed that questions 1–3 from have already been addressed here. For question 4 regarding the file input editor, I’ve provided guidance in this related thread: Width of File Custom Editor Is Too Large.
Please ensure to review those responses for a complete resolution.
As a general best practice, we kindly ask that each thread focus on a single, clearly scoped question. This helps us track and respond more effectively, and allows other community members to benefit from focused discussions. Additionally have in mind that heavily customized setups may fall outside of our guaranteed support boundaries.
That said, I’ll now go ahead and close this case. Feel free to continue the conversation in the other threads for any remaining concerns tied to their specific topics.
Best Regards,Arkan Ahmedov,Infragistics
Please test and lmk if you face any issue. I will be awaiting your response.
/community/cfs-file/__key/communityserver-discussions-components-files/1048/test.zipHello Arkan ,Here is the workiig sample sample.
Now follow the steps to replicate the issue:-
1) Keep the console open and click on add row. You will see that location of id column is giving validation error even without clicking anything which is not ideal. Also, when you cancel the validation message using cross the save button is enabled even when mandatory fields are not filled.2) File not getting removed:- When you add a file while adding a row and save the row. Its not showing the file back when edit. Also when you add or edit another row. Its showing the same file name next to the choose files. Ideally, it should be empty when adding new row again and when edit it should show current file name not the latest uploaded in the previous row.
3) When you open the html and edit any row its creating 2-3 duplicate transaction for each record. Can you help me out how to fix it.
You can check transactions by editing a row then saving and writing this in console:-
var transactions = $("#master_grid").igGrid("allTransactions");console.log(transactions);
4)Lastly i want to save attachment path after ajax can into the hidden column attachment_path and attachment_name in the current editor column.
The valuechanged is not defined or this.editor.destroy is not defined is coming very rarely idk why. Maybe check it if you can as its hard for me to replicate this.
Please answer this questions as all issues are interrelated and i have created a sample for you so it will be easy for you to identify them. Please acknowledge me once you receive this message.
Looking forward to your response.
Thanks and Regards
Rohit Rawat
Hello,Thank you for providing the sample code. Unfortunately, I’m unable to assemble and run it properly in its current fragmented state. To effectively assist you and reproduce the issue, I kindly ask that you prepare a single, runnable index.html file that includes all the relevant code (HTML, scripts, styles, and mock data) necessary to demonstrate the problem.
index.html
Once the sample is working on your end, please zip the file and send it to me. This will ensure that I’m working with the exact setup you're seeing and will significantly speed up troubleshooting.
Thank you for your understanding, and I appreciate your cooperation in making this process smoother.
Best Regards,Arkan AhmedovInfragistics
Would be waiting for your reply. Thanks