We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

I want to replace zero with hypher in data grid

Hi!

I want to replace zeros' in grid with hyphen.






3 Replies

PS Pavithra Subramaniyam Syncfusion Team November 14, 2022 06:34 AM UTC

Hi RJ,


Thanks for contacting Syncfusion support.


You can achieve your requirement by using the “valueAccessor” function, which provides the option for modifying the cell display value. Please refer to the below code example and documentation link for more information.


 

@{ 

    var valueAccessor = "valueAccessorFn";

}

 

<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" height="280">

    <e-grid-columns>

        <e-grid-column field="Freight" valueAccessor="valueAccessor" width="150"></e-grid-column> 

        .   .   .

    </e-grid-columns>

</ejs-grid>

 

<script>

    function valueAccessorFn(field, data, column){

        var value = data[field]

        if (data['Freight'] == 0) {

            value =  '_';

        }

        return value;

    }

</script>

 

 


https://ej2.syncfusion.com/aspnetcore/documentation/grid/columns/columns#valueaccessor


Please get back to us if you need further information.


Regards,

Pavithra S



RJ RJ November 29, 2022 08:02 PM UTC

Thank you for solution, i applied it in my solution but zero value replaced with blank not hyphen 


Following code i used 

function valueAccessorFn(field, data, column) {

        var value = data[field]

        if (data['pendingPRQty'] == 0) {

        value = '_';

        }

        return value;

    }




PS Pavithra Subramaniyam Syncfusion Team November 30, 2022 07:13 AM UTC

Hi RJ,


To validate further please share the below details which will be helpful for us to provide a better solution as early as possible.


  1. Sample data for the “pendingPRQty” field
  2. Column definition of the “pendingPRQty” field
  3. Share an issue reproducible sample if possible

Loader.
Live Chat Icon For mobile
Up arrow icon