jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Cells format not working
Tagged: Cells format not working
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 2 months ago.
-
AuthorCells format not working Posts
-
Hi,
I’m trying localization in jqWidgets grid. In that, the cellsformat is not working properly. In the below example i’m not able to set data like 25 or more in the “Unit Price” column.
Please help.<script type=”text/javascript”>
$(document).ready(function () {var getLocalization = function () {
var localizationobj = {};
localizationobj.pagergotopagestring = “Gehe zu:”;
localizationobj.pagershowrowsstring = “Zeige Zeile:”;
localizationobj.pagerrangestring = ” von “;
localizationobj.pagernextbuttonstring = “voriger”;
localizationobj.pagerpreviousbuttonstring = “nächster”;
localizationobj.sortascendingstring = “Sortiere aufsteigend”;
localizationobj.sortdescendingstring = “Sortiere absteigend”;
localizationobj.sortremovestring = “Entferne Sortierung”;
localizationobj.firstDay = 1;
localizationobj.percentsymbol = “%”;
localizationobj.currencysymbol = “€”;
localizationobj.currencysymbolposition = “after”;
localizationobj.decimalseparator = “.”;
localizationobj.thousandsseparator = “,”;
localizationobj.emptydatastring = “keine Daten angezeigt”;
var days = {
// full day names
names: [“Sonntag”, “Montag”, “Dienstag”, “Mittwoch”, “Donnerstag”, “Freitag”, “Samstag”],
// abbreviated day names
namesAbbr: [“Sonn”, “Mon”, “Dien”, “Mitt”, “Donn”, “Fre”, “Sams”],
// shortest day names
namesShort: [“So”, “Mo”, “Di”, “Mi”, “Do”, “Fr”, “Sa”]
};
localizationobj.days = days;
var months = {
// full month names (13 months for lunar calendards — 13th month should be “” if not lunar)
names: [“Januar”, “Februar”, “März”, “April”, “Mai”, “Juni”, “Juli”, “August”, “September”, “Oktober”, “November”, “Dezember”, “”],
// abbreviated month names
namesAbbr: [“Jan”, “Feb”, “Mär”, “Apr”, “Mai”, “Jun”, “Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dez”, “”]
};
var patterns = {
d: “dd.MM.yyyy”,
D: “dddd, d. MMMM yyyy”,
t: “HH:mm”,
T: “HH:mm:ss”,
f: “dddd, d. MMMM yyyy HH:mm”,
F: “dddd, d. MMMM yyyy HH:mm:ss”,
M: “dd MMMM”,
Y: “MMMM yyyy”
}
localizationobj.patterns = patterns;
localizationobj.months = months;
localizationobj.todaystring = “Heute”;
localizationobj.clearstring = “Löschen”;
return localizationobj;
}debugger;
var url = “../Content/Scripts/jqwidgets/Test/Prducts.xml”;
// prepare the data
var source1 =
{
datatype: “xml”,
datafields: [
{ name: ‘ProductName’, type: ‘string’ },
{ name: ‘QuantityPerUnit’, type: ‘int’ },
{ name: ‘UnitPrice’, type: ‘number’ },
{ name: ‘UnitsInStock’, type: ‘float’ },
{ name: ‘Discontinued’, type: ‘bool’ }
],
root: “Products”,
record: “Product”,
id: ‘ProductID’,
url: url
};
var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {
if (value < 20) {
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘; color: #ff0000;”>’ + value + ‘</span>’;
}
else {
return ‘<span style=”margin: 4px; float: ‘ + columnproperties.cellsalign + ‘; color: #008000;”>’ + value + ‘</span>’;
}
}
var dataAdapter = new $.jqx.dataAdapter(source1, {
downloadComplete: function (data, status, xhr) { },
loadComplete: function (data) {
debugger;
},
loadError: function (xhr, status, error) { }
});
// initialize jqxGrid
$(“#jqxgrid”).jqxGrid(
{
width: 670,
source: dataAdapter,
theme: ‘web’,
pageable: true,
autoheight: true,
sortable: true,
altrows: true,
enabletooltips: true,
editable: true,
selectionmode: ‘multiplecellsadvanced’,
localization: getLocalization(),
columns: [
{ text: ‘Quantity per Unit’, datafield: ‘QuantityPerUnit’, cellsalign: ‘right’, align: ‘right’, width: 120 },
{ text: ‘Unit Price’, datafield: ‘UnitPrice’, cellsformat: ‘d3’, width: 100 },
{ text: ‘Units In Stock’, datafield: ‘UnitsInStock’, cellsformat: ”, width: 100 },
{ text: ‘Discontinued’, columntype: ‘checkbox’, datafield: ‘Discontinued’ }
]
});
});
</script><div id=”jqxgrid”>
</div>Hi,
I like to restrict the column to 3 decimal precision like 45.345. How to achieve this?
Thanks,
SadeeshHi Sadeesh,
So the format should be “f3”.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.