Hello,
we enter some number into a cell and at leaving this cell, we fire an ajax request to autocomplete some cells in this row. this works good for existing rows (rowid exists on tr data-id) and also for new rows (no row id).
our setValue wrapper for existing and new rows:
setCellValue: function (gridId, rowId, colKey, value) { if (rowId == undefined || !rowId || rowId == "") { $("#" + gridId).igGridUpdating("editorForKey", colKey).igEditor("value", value); } else { $("#" + gridId).igGridUpdating("setCellValue", rowId, colKey, value); } }
problem: we also need to set values to hidden columns. this works, if the hidden cell is not in a new row, an id exists. writing into a hidden cell using "editorForKey" does not work, because there is no editor for a hidden cell.
any idea how to resolve this issue? we prefer nice solutions :) (without setting some global stuff and setting cell at rowEditingEnded or so.. :) )
thanks in advance.
Hello Max,
Thank you for contacting Infragistics!
We received your support request concerning autocompletion of cells in the igGrid, and I have been assigned to assist you on the matter. Infragistics is dedicated to helping you solve this issue. Our team and I have done an initial review of your request and I will be researching the behavior you are describing to try and find an alternative for you. I will get back to you by the end of the day tomorrow with more information or questions for you.
After reviewing your request, I have a few questions for you. When is the setCellValue function you have being fired? Is it being called on the editCellEnding event? The reason I am led to believe this is because you said that after leaving a cell, you fire an ajax request to autocomplete some cells in this row. Also, this set setCellValue function is not meant to be confused with the setCellValue method we have in igGridUpdating, correct? I wanted to be sure because the names of the two were the same and wanted to make sure there was no confusion there. Also, could you clarify your problem statement a bit for me. In particular, I was unable to understand the situation where your method was not working. Is it only when you do add new row that you have this issue? It may be very helpful to me if you could provide a short, isolated sample showing this issue, or just provide the code which pertains to the igGrid and this issue in particular. I look forward to hearing back from you so that I can look into providing a solution for you as soon as possible.
When the valueChanged event of an specific editor is fired, we use the entered value of that cell and do an ajax request do get some additional values from the server. afterwards, we use our setCellValue function (which is a wrapper of the igGridUpdating or the .igEditor("value", value) function, depends on whether we want to set a cell in a new or existing row) to set the values into the cells.
[###
$("#" + gridId).igGridUpdating("setCellValue", rowId, colKey, value); does only work, if the row still exists. that means you are only able to edit existing rows with this method.
to edit a new row (rowID is still -1, row never fired generatePrimaryKeyValue, Done was never clicked) it is only possible to set the values into the editors using $("#" + gridId).igGridUpdating("editorForKey", colKey).igEditor("value", value);
###]
the problem only occurs, if you try to set a value to a hidden column-cell if the row is new (so never clicked "done" to get it into transactionlog/to get it comitted, ...). a hidden cell has no editor, so you can not call editorForKey to set the value.
we use a dirty workaround now: if a new cell (we want to set a value to) is hidden, I set the defaultValue of that cell and at rowEditingEnding, igGridUpdating is automatically using the defaultValue for that cell. This kills the common defaultValue functionality, but works for us at the moment.
did I miss a built-in way to solve this?
please provide a real solution. :)
yours.
After reviewing your post with my team, I am not sure that what you're doing has a 'real' solution as you suggest. Because this is a custom implementation, and no editor is created for hidden columns, there are no built-in ways for you to solve this. If your workaround is working successfully for you now, I would stick with that. The only other option I can see is if you manually edit the actual data set and send that back to your server. In other words, if you have JSON data, you can try adding the value for the hidden column directly into the new JSON object you are creating and adding to your data source rather than adding it through the grid. This way, you keep the Grid, which is not meant to do this sort of operation on hidden columns, out of the transaction and still have a value for the hidden column. Please let me know if you have any further questions.
hi, well, our workaround works for us atm.
but I think there should be a built-in feature to add a new row and set values to all cells (including hidden ones) by javascript. it is possible to write to hidden columns in existing rows and should also be possible to write to new rows.
In addition I do not understand why your setCellValue method can not set values to new rows, that does not make sense (seen as an user of your grid, I know that there are technical differences in new and existing rows) at all. Please add this features.