I am scratching my head with this one. My code appears correct but when I select in the view to add a row it is actually calling the edit in the controller. I know this because I get an error when I save. I changed the error message in my controller to verify that the message was coming from the edit code. Is there something I am not seeing here? thanks for your help.

"...when I select in the view to add a row it is actually calling the edit in the controller.."
Is it possible that it thinks you have edited the row that's losing focus? You click view to add a new record. In order to do that it has to leave the record that was selected on startup...? What's the value of customer at that point? Perhaps it's null and all you need is a check for a null entity to exit.

Right now the table is empty. There is no row selected. I will put a record in the table manually as I did before to make sure it was showing in the grid. I deleted them with the delete button so both of those work. I also have a users table that appears to be working but it already has records in the table. I will post my findings. However if this is the case, why does it require that there be data in the table before it will work?

Okay added a record manually. Not sure what is going on. It still uses the edit and when I go to edit a record it saves it in the table as a new record. So edit is using add and add is using edit????

The code that would invoke the save isn't posted so I'm not sure, but what I thought might be happening is that the save is triggered by some event in the grid. It appears that the event is being triggered for you when there's no currently selected record. So the controller gets called with a customer == null. Are you able to break the operation and view the call stack to see from where the update is being called?

The save is the 'Create Customer' in the controller section above. I will have to look at it later. The same code is being used in another table and it works, that is what it confusing to me. I thought I may have missed something in the copy.

1 solution

Solution 1

After much debugging I have found that Jqgrid must work on Indexing. It does matter what order you put the JavaScript code in. I had the edit before the add. switching it so that the add was before the edit in the code works. So Jqgrid goes to the area, I am guessing by indexing, in the code. Since edit was where the add should have been it was using the edit for the add button.

I can say that I do not agree with this method. However it is not mine to say. You would think that it would just grab the code where ever and whenever it is needed.
Lesson learned.