@Html.EJS().Tooltip("allTabtooltip").Target(".e-unboundcelldiv").ContentTemplate(@<div>
@Html.EJS().Created("created").Columns(col =>
----
}).Render()
</div>).Render()
<script>
function created(args) {
// check the machine is mobile or desktop
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if (isMobile) {
for (var i = 0; i < this.columns.length; i++) {
// unfreeze the column
this.columns[i]["isFrozen"] = undefined;
}
// refresh the columns to affect the changes in Grid
this.refreshColumns();
}
}
</script>
|
[index.cshtml]
@Html.EJS().Grid("FrozenGrid").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowSelection(false).AllowResizing().Height("410").Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Width("140").IsFrozen(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Freight").HeaderText("Freight").Width("140").IsFrozen(true).Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").IsFrozen(true).Width("200").Add();
col.Field("ShipName").HeaderText("Ship Name").Width("150").Add();
col.Field("ShippedDate").HeaderText("Shipped Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("ShipCity").HeaderText("Ship City").Width("200").Add();
col.Field("ShipAddress").HeaderText("Ship Address").Width("150").Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();
}).DataBound("dataBound").Render()
<script>
var flag = true;
function dataBound(args) {
if (flag) {
flag = false;
// get the screenwidth var screenWidth = window.innerWidth;
// make the condition as you want
if (screenWidth <= 800) {
for (var i = 0; i < this.columns.length; i++) {
// unfreeze the column
this.columns[i]["isFrozen"] = undefined;
}
// refresh the columns to affect the changes in Grid
this.refreshColumns();
}
}
}
</script> |
[index.cshtml]
@Html.EJS().Grid("FrozenGrid").DataSource((IEnumerable<object>)ViewBag.DataSource).AllowSelection(false).AllowResizing().Height("410").Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Width("140").IsFrozen(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("Freight").HeaderText("Freight").Width("140").IsFrozen(true).Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("OrderDate").HeaderText("Order Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("CustomerID").HeaderText("Customer Name").IsFrozen(true).Width("200").Add();
col.Field("ShipName").HeaderText("Ship Name").Width("150").Add();
col.Field("ShippedDate").HeaderText("Shipped Date").Width("130").Format("yMd").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("ShipCity").HeaderText("Ship City").Width("200").Add();
col.Field("ShipAddress").HeaderText("Ship Address").Width("150").Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();
}).DataBound("dataBound").Render()
<script>
var flag = true;
// bind resize to the window
window.addEventListener("resize", windowResize);
function windowResize(args){
var screenWidth = window.innerWidth;
var grid = document.getElementById("FrozenGrid").ej2_instances[0];
// get the grid columns
var columns = grid.getColumns();
// unfreeze the column for smaller screen
if (screenWidth <= 800) {
if(grid.element.getElementsByClassName('e-frozencontent').length > 0){
for (var i = 0; i < columns.length; i++) {
if( columns[i].field == "OrderID" || columns[i].field == "Freight" || columns[i].field == "CustomerID"){
columns[i]["isFrozen"] = undefined;
}
}
// refresh the columns to affect the changes
grid.refreshColumns();
}
}else{
// freeze the columns for bigger screen
if (grid.element.getElementsByClassName('e-frozencontent').length == 0){
for (var i = 0; i < columns.length; i++) {
if( columns[i].field == "OrderID" || columns[i].field == "Freight" || columns[i].field == "CustomerID"){
columns[i]["isFrozen"] = true;
}
}
// refresh the frozen columns to affect the changes
grid.freezeRefresh();
}
}
}
function dataBound(args) {
if (flag) {
flag = false;
// get the screenwidth
var screenWidth = window.innerWidth;
// make the condition as you want
if (screenWidth <= 800) {
for (var i = 0; i < this.columns.length; i++) {
// unfreeze the column
this.columns[i]["isFrozen"] = undefined;
}
// refresh the columns to affect the changes in Grid
this.refreshColumns();
}
}
}
</script>
|