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())
Hello Rosco,
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.
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,