Calculating Computed Columns in a master-detail grid

QuestionsCalculating Computed Columns in a master-detail grid
Gary Wilson asked 9 months ago

Hi Abu,

I have a master grid of cars where you select one and the price plus mileage is communicated to the detail grid as subgridparams. As you know from my code, this works very well. However, in the detail grid, I want for each row to take the price and mileage of the competitive car and subtract from these the price and mileages from the master grid to provide the difference. For example, I select a car costing £10,000 in the top grid and in the detail grid the first row has a car costing £8,000 so I want to show £2,000 in the Price Diff column and so on for each row.

I created a function and event for the do_onload of the detail grid. I know how to get the values of the subgridparams. I can for each row in the detail grid get the price and mileage of each car. How do I set the value of the Price Diff and Mileage Diff columns? Do they have to be editable=true? For example, I tried:

jQuery(‘[name=”car_mileage_diff”].editable’).val(mileage – comp_mileage);

Thanks,

Gary

2 Answers
Gary Wilson answered 9 months ago

I figured out the following code:

st = (mileage – comp_mileage).toString();
jQuery(‘#comp tr.jqgrow:eq(‘+i+’)’).find(“td:eq(11)”).html(st);

but how do I use the column name rather than the column number?

Thanks
Gary

Abu Ghufran Staff answered 7 months ago

Just to log the solution, better way to pick column is to use aria-describedby attribute.

Instead of td:eq(11)

You can use:

td[aria-describedby="list1_colname"]

where list1 is grid id and colname is column name.

jQuery('#comp tr.jqgrow:eq('+i+')').find("td[aria-describedby=list1_colname]").html(st);
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

19 + 10 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?