PDA

View Full Version : [CLOSED] SummaryRenderer Format



matrixwebtech
Jul 13, 2014, 8:01 PM
I found Ext.util.Format.usMoney,Is there any thing for Indian rupee.

Daniil
Jul 14, 2014, 1:57 PM
Hi @matrixwebtech,

Unfortunately, no.

But, fortunately, that you can always implement your own Renderer. This thread might help.
http://forums.ext.net/showthread.php?35641

matrixwebtech
Oct 03, 2014, 7:35 AM
Hi daniil,with your example I try

Example View

<script type="text/javascript">

Ext.util.Format.indianMoney = function (v) {

v = String(v).replace(/[^0-9.\-]/g, "");
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);

var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.' + ps[1] : '.00',
r = /(\d+)(\d{3})/;

while (r.test(whole)) {

whole = whole.replace(r, '$1' + ',' + '$2');
}

return "₹ " + whole + sub;
};

</script>
@X.ResourceManager()

@(

Html.X().GridPanel()
.ID("GridPanel1")
.Store(
Html.X().Store()
.DataSource(ViewBag.loadgrid)
.Model
(
X.Model()
.ID("mid")

.Fields
(
X.ModelField().Name("text").Type(ModelFieldType.String),
X.ModelField().Name("value").Type(ModelFieldType.Float)
)

)
)
.ColumnModel(
Html.X().Column().DataIndex("text").Text("text").Flex(1).StyleSpec("text-align:right"),
Html.X().Column().DataIndex("value").Text("value").Flex(1).StyleSpec("text-align:right")
.Renderer("Ext.util.Format.indianMoney")
)


)
Example Controller

public class textalignController : Controller
{
//
// GET: /textalign/

public ActionResult Index()
{
ViewBag.loadgrid = getSampleData();
return View();
}


private List<textalign> getSampleData()
{
List<textalign> _textalign = new List<textalign>();
_textalign.Add(new textalign
{

text = "Sample text",
value = 10.36,

});
_textalign.Add(new textalign
{

text = "some more Sample text",
value = 25.38,

});

return _textalign;
}
}

public class textalign
{
public string text { get; set; }
public double value { get; set; }
}

the Indian rupee symbol displayed in Firefox ,but not in chrome(Version 37.0.2062.103 m) and IE 11.

Daniil
Oct 03, 2014, 9:17 AM
Please try


...
alert('I am here.');
return "₹ " + whole + sub;
to ensure the code is actually executed.

If it is not executed, please try to clear a browser's cache.