Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
148168 | Oct 8,2019 09:35 PM UTC | Oct 17,2019 01:37 PM UTC | Vue | 9 |
![]() |
Tags: Data Grid |
<template>
<ejs-grid . . . . :toolbar="toolbar" >
<e-columns>
<e-column field="OrderID" headerText="Order ID" :isPrimaryKey="true" width="100"></e-column>
. . . . .
<e-column headerText="Icon" width="120" :valueAccessor="valueAccess"></e-column>
</e-columns>
</ejs-grid>
</template>
<script>
export default {
name: "App",
data: () => {
return {
. . . .
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"]
};
},
methods: {
valueAccess: function(field, data, column) {
const date2 = new Date(); // current date
const date1 = data.OrderDate; // Order date from data source
const diffTime = Math.abs(date2 - date1); // find difference
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
if (diffDays <= 12) {
// you can apply whatever conditions you need
return '<span class="e-icons e-date"></span>'; // icons from our library
} else return '<span class="e-icons e-upload"></span>';
}
};
</script>
<style>
@import "https://cdn.syncfusion.com/ej2/material.css";
.e-upload:before {
content: "\e208";
}
.e-date:before {
content: "\e901";
}
.e-icons {
color: #00ffff;
font-size: 16px;
}
</style>
|
btnClick: function(event) { //achieved in button click
this.$refs.gridObj.dataSource[0].OrderDate = new Date("5/5/2019"); // you can change the value whatever you want
this.$refs.gridObj.refresh();
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.