PDA

View Full Version : [CLOSED] Column visibility



RRD
Jul 17, 2013, 12:28 PM
I have page with Grid. All data for grid (column model etc) added in cs code. For some columns set visibility to false. I need to make this columns visible using javascript. There no this columns in Grid.Columns property.
Where I could find this columns and how to make them visible? Or Should I make them visible by default and set visibility to false in Grid AfterRender?

RCN
Jul 17, 2013, 12:33 PM
Try to use Column's Hide method.

RRD
Jul 17, 2013, 12:42 PM
Try to use Column's Hide method.

Columns already invisible. I need to make them visible.

RCN
Jul 17, 2013, 12:53 PM
So, try to use Column's show method.

Daniil
Jul 17, 2013, 4:55 PM
Hi,

I guess you are using the Visible property, aren't you? I think it is better to use the Hidden one. The difference is explained here:
http://forums.ext.net/showthread.php?13114#post54033

Then you will be able to show such a Column by the show method call as Raphael suggested.

RCN
Jul 17, 2013, 5:17 PM
Please, take a look on the following example:



<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">
var hide = function () {
App._grd.columns[1].hide();
}
var show = function () {
App._grd.columns[1].show();
}
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Button Text="HIDE Second Column" runat="server">
<Listeners>
<Click Handler="hide();" />
</Listeners>
</ext:Button>
<ext:Button Text="SHOW Second Column" runat="server">
<Listeners>
<Click Handler="show();" />
</Listeners>
</ext:Button>
<ext:GridPanel ID="_grd" runat="server" Title="Records" Frame="false" Width="500" Height="500">
<Store>
<ext:Store runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="Address" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" DataIndex="Name" runat="server" />
<ext:Column Text="Address" DataIndex="Address" runat="server" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</body>
</html>




namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords()
{
List<Person> lst = new List<Person>();

for (int index = 0; index < 15; index++)
{
lst.Add(new Person
{
ID = index,
Name = "Name" + index,
Address = "Address" + index,
});
}

return new StoreResult(lst, lst.Count());
}
}

[Serializable]
public sealed class Person
{
public int ID { get; set; }

public string Name { get; set; }

public string Address { get; set; }
}
}


I would also recommend you to take a look on the following thread: http://forums.ext.net/showthread.php?21014-CLOSED-Set-column%B4s-hideable-property-using-JavaScript

RRD
Jul 18, 2013, 1:13 PM
Hi,

I guess you are using the Visible property, aren't you? I think it is better to use the Hidden one. The difference is explained here:
http://forums.ext.net/showthread.php?13114#post54033

Then you will be able to show such a Column by the show method call as Raphael suggested.

You was right. I used Visible property. I am using hidden right now. Thanks for help. You can close this thread.

RCN
Jul 18, 2013, 1:22 PM
You're welcome. Let us know if you need further assistance.