SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 298 forks source link

dgrid version 1.3.3 is breaking formatter function in dgrid #1477

Closed pnaqati closed 3 years ago

pnaqati commented 3 years ago

columns:{ col1: { selector: 'checkbox', label:''} ,
id: { hidden :true ,unhidable: true}, content:{label:'Photo',field:"_item", formatter: function(item){
if(!item){
return; }else
{

                             return "<div id=\"productImageDiv\"><img src=\"/getProductImage/" + item.id +','+1+ "\"  width=\"100%\" height=\"100%\" style=\"vertical-align: middle\" alt="+ item.typeName +" /> </div> ";                                                     
                        }
                        }                       
                },
                description: {label:'Description', field:"description",formatter: function (value) {                        
                     return '<div id="shopProductDescription">'+value+'</div>'; 
                }} , 
                sdescription: {label:'Description', field:"sdescription",formatter: function (value) {                      
                     return '<div id="shopsProductDescription">'+value+'</div>'; 
                }} ,                    
                companyname: { label: 'Supplier',id: 'companyid',renderCell: contactSupplier}, 
                discount : {label:'Discount', field:"discount",formatter: function (value) { 
                     var num=number.format(value, {places:0});
                     if (num > 0 )
                     return '<div id="discountCurrency">'+num+'%<span>&nbsp;</span> </div>';
                     else
                     return '<div id="discountCurrency"> </div>';    
                }} ,
                cost : {label:'Price (CAD)', field:"cost",formatter: function (value) { 
                     var num=number.format(value, {places:2,pattern:'########.##'});    
                     return '<div id="productCurrency">$<span>&nbsp;</span>'+num+'</div>';
                }} ,

Capture Capture

pnaqati commented 3 years ago

I changed formatter with renderCell function and this issue is resolved

msssk commented 3 years ago

This is a documented breaking change in 1.3.0 aimed at making dgrid more secure by default and reducing the chance of accidental XSS. formatter can still be used with HTML strings by providing an object with an html property (see documentation).