I am having a difficult time figuring out how to update my iggrid data programmatically.
I am developing a MVC4 application and I initially set my iggrid (let's call it grid1) in my razor view using the MVC wrapper's DataSourceURL method. My grid renders and displays my data fine.
My grid1 contains 5 columns: 3 bound columns from my model (ProductName, Description, Price) and two unbound columns (Tax and TotalTax). The TotalTax column has a formula (CalcTotalTax) attached to it which simply displays the Tax * Price.
What I am trying to achieve is I have an igTextEditor also on the view that the user will enter their local Tax rate into. I have added a client side event to the valueChanged event of this igTextEditor (let's call it text1). I want to be able to take this tax rate and put it into each row of the grid1's Tax column. I then want the TotalTax field to automatically run its formula to determine the total tax. I can't seem to figure out the jQuery syntax to properly insert the tax rate into each row of my grid1. I just want the user to be able to enter in various tax rates and be able to see what the corresponding total tax would be for each product that is listed in the grod (it could hundreds of rows). I'm assuming this is possible but perhaps someone can shed some more light on this for me, I'm still learning Ignite, MVC and jquery!
Thanks.
Rosco
<script type="text/javascript">
function CalcTotalTax(row, grid) {
return row.Price * row.Tax;
}
function SetTax(evt, ui) {
**put the ui.value into each Tax column of each row in grid1 **
</script>
@(Html.Infragistics().TextEditor()
.ID("text1")
.AddClientEvent("valueChanged", "SetTax")
.Width(50)
.Render())
I guess I don't need to attach my sample anymore, you have answered all of my questions. Thank you so much again, I hope others find this sample as useful as I have.
regards,
Hello Rosco,
There is an option igGrid.autoCommit which controls how the changes made to the grid are propagated back to the data source. When igGrid.autoCommit = FALSE then the changes are stored in a temporary transaction log and the data source cannot see them until igGrid.commit API method is called. If the data is not committed the changes are styled in italics font.
On the other hand when igGrid.autoCommit = TRUE the changes are directly propagated to the data source and there are no styling changes on the grid. In this mode the Summaries are calculated on demand right after the change. My sample uses the autoCommit = TRUE mode so is you enable Summaries feature it will work as expected. I'm attaching a modified sample for your convenience.
P.S.: You can attach a sample from the "Options" tab when you write a new post. However there is a limit of 200Kb per attachment. Also you should zip it first.
Hope this helps,
Martin Pavlov Infragistics, Inc.
Hello Martin,
Thank you for the prompt response. I was able to extend the concepts from your sample and got it working! I do, however, have a couple followup questions.
The first is when the data gets updated on my grid it changes the entire grid's font to italics. Do you know why that would happen? It doesn't seem to happen on the sample that you provided.
The second is I am also using Summaries and need to be able to recalculate those based on the updated data. I'm assuming I need to use the 'igSummaries calculateSummaryColumn' API method but I can't seem to get it working. I have extended your sample to include summaries and was wondering if you could look to see what I am missing. Please let me know how I can attach this updated sample, I'm not sure how to get it to you through this post.
Thanks,
You can use the igGridUpdating.updateRow API to update the Tax and TotalTax columns.
Attached you can find a complete sample.
Best regards, Martin Pavlov Infragistics, Inc.