Hi,
I need to show/hide some columns of my igGrid based on the selection of igCombo. I can only commit the rows when the user posts the form. I do my own manual commit & I am not using 'saveChanges' metod of igGrid because of various reasons. The problem I am facing is that the grid may have pending transactions in it and I dont want to lose them while hiding/showing the columns on dropdown selection changed event. When I hide a column through igGrid's hideColumn method the grid logs an error that commit the rows in the grid before doing this. But if I commit these rows, I wont get them in igTransactions later on when the form is posted. I dont want to lose the transactions & I also dont want to commit the rows before hiding/showing columns because the user might edit the existing transactions before submitting the form. Auto commit is set to false for a reason and I cannot set it to true because it will mess up some other things.
Is there a way to persist the transactions before hiding/showing columns of the grid without commiting them. Or if commiting is the only options, would I still get them in 'igTransactions' ? If you could provide a short sample in which we can show/hide columns of a grid on any event WITH uncommitted data rows still in the grid, that would save me alot of time.
Thanks for your time.
Hello Jimmy,
I am glad that you find my suggestion helpful.
Please let me know if you need any additional information regarding this matter.
Thanks for the reply Vasya regarding the order of allTransactions. I am now using $("#myGrid").igGrid("commit"); explicitly before showing/hiding columns and this lets me show hide columns without setting autoCommit to true.
I appreciate your help, Thanks.
Thank you for getting back to me.
What I can suggest regarding your first question is using the allTransactions. What`s more, it is safe to use the collection returned by this method because as mentioned in my previous post the transactions are always listed in order - last transaction is the most recent one. This means that you could safely use allTransactions to get reference to the transaction collection and handle it to meet your requirement. If you could access all the transactions that are currently not committed to the server I believe this will help you achieve your requirement.
Since you are using your own saveChanges method you could locally modify this collection and exclude all the transactions you consider irrelevant to your scenario.
Please let me know if you have any additional questions regarding this matter.
Hello Vasya,
Thanks for the detailed response. I understand what you are trying to say however my grid has autocommit set to false, & if I set it to true it will mess up some features of my View which are currently in running condition. Therefore I was hoping I could achieve some workaround for this issue without setting autoCommit to true.
Q#1: Is it possible to save a copy of the pending transactions in a javascript object array, and then do a manual commit (Not an actual server commit But a commit just for the sake of emptying the pending transactions on the client) so that the grid's columns could be hidden and shown & after performing those operations I set the real transaction log equal to the previously saved copy of pending transactions object array? Is it possible ? If yes could you tell me how.
Q#2: You said that "all the transactions are in a particular order, last transaction Is the most recent" . Will this be true every time? Will it be safe to write a routine which would iterate through the transactions array and get the last existence of a record with particular rowId and discard all the other assuming that the last "row" type record would be the final changed record from the client side? The last existing row with a particular rowId will always be the latest one regardless of client browsers or LoadTransactions<> method?
Thanks in advance, I appreciate your help.
Hello Jimmy Page,
Thank you for posting in our community.
Currently it is not possible to hide columns before committing pending transactions. However, what I can suggest is using the allTransactions method from the igGrid API. It returns a list of all transaction objects that are either pending, or have been committed in the data source. For instance:
[code]
var
transactions = $(
".selector"
).igGrid(
"allTransactions"
);
[/code]
This way you are going to have access to all the transactions and no transactions are going to be lost.
Please keep in mind that transactions are not going to be aggregated, which basically means that every time a new editing action is performed in the grid will be a separate transaction.
Additionally, all the transactions are in a particular order, last transaction Is the most recent, respectively if you process them on the server in the same order the correct result should be retrieved.
I hope you find this information helpful.
Please let me know if you need any further assistance with this matter.