PDA

View Full Version : [CLOSED] Change the syle of EmptyText



RCN
Jun 04, 2012, 4:34 PM
Hi folks, i have a GridView with EmptyText property set with "xxx". i want to change the style of the message.

i tried to accomplish this task using the solution found at http://forums.ext.net/showthread.php?3406-How-to-display-an-Empty-Text-label-in-GridPanel but i was not successful.



<style type="text/css">
.x-grid-empty {
text-align: center;
}
</style>




<Render Handler="el.getView().refresh()" Delay="100" />

RCN
Jun 04, 2012, 4:43 PM
I can´t accomplish it by setting both GridView´s EmptyText and DeferEmptyText properties.


grd.View.Add(new GridView { TrackOver = true, EmptyText = "message", DeferEmptyText = false });


But if i set the GridPanel´s EmptyText property and GridView´s DeferEmptyText it works.


GridPanel grd = new GridPanel
{
ID = "_grd",
EmptyText = "message"
};
grd.View.Add(new GridView { TrackOver = true, DeferEmptyText = false });


Is this behaviour expected?

Daniil
Jun 04, 2012, 7:15 PM
Hi,

If you want an empty text to be wrapped in a <div> with "x-grid-empty" CSS class (it will allow to easily stylize it), then yes, you should set up EmptyText for GridPanel.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>

<style type="text/css">
.my-grid .x-grid-empty {
color: red;
}
</style>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel
runat="server"
Height="100"
Cls="my-grid"
EmptyText="EmptyText">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<View>
<ext:GridView runat="server" DeferEmptyText="false" />
</View>
</ext:GridPanel>
</body>
</html>

Setting up EmptyText for GridView shows that EmptyText, but it's not stylized.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel runat="server" Height="100" >
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<View>
<ext:GridView runat="server" EmptyText="EmptyText" DeferEmptyText="false" />
</View>
</ext:GridPanel>
</body>
</html>

RCN
Jun 04, 2012, 7:25 PM
Thank you Daniil, please mark is as resolved