[Vtigercrm-developers] vt7: How to update field from Javascript

Alan Lord alanslists at gmail.com
Mon Jan 23 11:53:20 GMT 2017


Thanks for the follow up.

I've now got it working but it is a big of a "dogs dinner" frankly.

First I need to grab the container (td) for the field or your suggestion 
of using .parents() means I end up updating *every* currency field on 
the page ;-)

> var svcChargeContainerId = '#'+moduleName+'_detailView_fieldValue_svc_charges';
> var svcChargeContainer = jQuery(svcChargeContainerId);

Then, once I've done the calculations I update the value in three places:

> svcChargeContainer.find('span.currencyValue').html(svcCharge);
> svcChargeContainer.find('input[data-name="svc_charges"]').attr('data-displayvalue', svcCharge);
> svcChargeContainer.find('input[data-name="svc_charges"]').data('value', svcCharge); // This one doesn't work...

It would be very helpful, for everyone if there was an API in the main 
Detail and Edit view Javascript classes to support dynamic updating of 
fields.

Now I need to trigger a save event on the Service Charge field and then 
work out how to do the same thing in Edit View.

Then, the next thing I have to do is to try and sort out the picklist 
problems... See thread "Re: Q. on vt7 Detail/Summary view picklists"

Thanks for helping.

Alan


On 20/01/17 18:08, Susruthan Seran wrote:
> I hope this will help you.
>
> $('input[data-name="svc_charges"]').parents().find('.currencyValue').html("test");
>
> Replace the *test  *with your value to show. I'm not much familiar with
> Detail_js but will solve your problem I hope.
>
>
> On 01/20/2017 09:11 PM, Alan Lord wrote:
>> On 20/01/17 15:19, Susruthan Seran wrote:
>>> Try this..
>>>
>>> jQuery('input[data-name="svc_charges"]').attr('data-displayvalue',100);
>>
>> It's getting somewhere...
>>
>> In firebug that element now looks like:
>>
>>> <input class="fieldBasicData" data-name="svc_charges"
>>> data-type="currency" data-displayvalue="2264.177655529488"
>>> data-value="0.00" type="hidden">
>>
>> But this has not updated the value visible to the end-user. This is in
>> the two nested <span> above the input tag...
>>
>> I would have assumed that there would be some kind of API for this
>> kind of thing in the Detail_js class or similar but I've been hunting
>> around the code and can't find anything.
>>
>> And picklists are just a nightmare... They really do seem to be empty
>> until you click the pencil icon to edit them :-(
>>
>> Al
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>
>
>
> _______________________________________________
> http://www.vtiger.com/
>




More information about the vtigercrm-developers mailing list