Value Force display 4 digits after decimal point

Source: Internet
Author: User

How to call Ajax:

$.each (data. Resultset,function (I,ele) {                ele. Mtur_yld = cellRenderNum100 (null, "Mtur_yld", Ele. MTUR_YLD);                Ele. Tmt_yld = cellRenderNum100 (null, "Tmt_yld", Ele. TMT_YLD);            })

Jqwidgets:jqxgrid Call Mode:

Source:  {                     localdata:data. RESULTSET,                     datatype: "Array",                     datafields: [                                   {name: ' qtn_id ', type: ' int '},                                   {name: ' Term_beg ', type: ' s Tring '},                                 {name: ' Term_end ', type: ' String '},                                  {name: ' Mtur_yld ', type: ' String ', Cellsrenderer: CELLRENDERNUM100},                                  {name: ' Tmt_yld ', type: ' String ', cellsrenderer:cellrendernum100}                    ]                 },

Method:

Take 4 digits after the decimal point and force display 4 digits after the decimal point @author zhangyunyang 2014-12-18function cellRenderNum100 (row, Columnfield, value) {    var value _str=string (value*100);    if (value_str.length>6) {        value_str=value_str.substring (0,6);    } else{        if (Value_str.indexof (".")! =-1) {            var varr=value_str.split ('. ');            var rlg=4-varr[1].length;            for (Var i=0;i<rlg;i++) {                value_str=value_str+ "0";            }        } else{            value_str=value_str+ ". 0000";        }    }    return VALUE_STR;}


Value Force display 4 digits after decimal point

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.