PDA

View Full Version : Grid panel header was not displaying



sundarsureshin
Feb 10, 2015, 12:13 PM
Grid panel header was not displaying when i open an view page, how to display grid panel header rows all time.

RCN
Feb 10, 2015, 8:40 PM
Please post a complete (but simplified) code sample demonstrating how to reproduce the issue.

RCN
Feb 10, 2015, 8:41 PM
Be sure that you're not setting GridPanel's HideHeaders to true.

RCN
Feb 10, 2015, 8:44 PM
The following example may help you.

20851



<!DOCTYPE html>
<html>
<head runat="server">
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel Title="Ext.Net" Border="true" Width="500" Height="370" runat="server">
<Store>
<ext:Store AutoLoad="true" runat="server">
<Proxy>
<ext:AjaxProxy Url="~/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader RootProperty="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model IDProperty="ID" runat="server">
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="LastName" 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" Flex="1" DataIndex="Name" runat="server" />
<ext:Column Text="Last Name" DataIndex="LastName" 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<Entity> lst = new List<Entity>();

for (int index = 0; index < 15; index++)
{
lst.Add(new Entity
{
ID = index,
Name = string.Format("Name - {0}", index),
LastName = string.Format("Last Name - {0}", index),
Address = string.Format("Address - {0}", index)
});
}

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

public class Entity
{
public int ID { get; set; }

public string Name { get; set; }

public string LastName { get; set; }

public string Address { get; set; }
}
}

sundarsureshin
Feb 11, 2015, 5:14 AM
i have created a grid panel for role based designation of an employee, and it was suppose to display as shown below image
20921

Code for the grid panel is



@(Html.X().GridPanel()
.ID("GPDesignation")
.Width(1158)
.Height(260)
.Header(true)
.Store(Html.X().Store()
.PageSize(10)
.ID("SDesignation")
.Model(Html.X().Model()
.Fields(
new ModelField("ROLE_CODE", ModelFieldType.String),
new ModelField("ROLE_DESC", ModelFieldType.String),
new ModelField("DESIGNATION_CODE", ModelFieldType.String),
new ModelField("DESIGNATION_DESC", ModelFieldType.String),
new ModelField("DEFAULT_DESIG", ModelFieldType.String)
)
)
)
.ColumnModel(
Html.X().Column().Text("Role").DataIndex("ROLE_CODE").Width(150),
Html.X().Column().Text("Role Description").DataIndex("ROLE_DESC").Width(326),
Html.X().Column().Text("Designation").DataIndex("DESIGNATION_CODE").Width(250),
Html.X().Column().Text("DSG Description").DataIndex("DESIGNATION_DESC").Width(326),
Html.X().Column().Text("Default").DataIndex("DEFAULT_DESIG").Width(100)
)
.SelectionModel(Html.X().RowSelectionModel().Liste ners(ls => ls.Select.Fn = "GridSelect"))
)


Data's binded to the grid using ajax jsonResult



public JsonResult Bind_Destination(string EMP_CODE)
{
List<Designation_Model> Designationlist = new List<Designation_Model>();
try
{
InitializeDB();
List<DbParams> collection = new List<DbParams>();
collection.Add(new DbParams(DbType.String, 50, "BindEmployeeDestinationgrid", "@Mode", ParameterDirection.Input));
collection.Add(new DbParams(DbType.String, 200, EMP_CODE, "@EMP_CODE", ParameterDirection.Input));
DataSet ds = ObjDbfactory.GetData("SP_Employee", false, collection);

foreach (DataRow dr in ds.Tables[0].Rows)
{
Designationlist.Add(new Designation_Model
{
ROLE_CODE = Convert.ToString(dr["ROLE_CODE"]),
ROLE_DESC = Convert.ToString(dr["ROLE_DESC"]),
DESIGNATION_CODE = Convert.ToString(dr["DESIGNATION_CODE"]),
DESIGNATION_DESC = Convert.ToString(dr["DESIGNATION_DESC"]),
DEFAULT_DESIG = Convert.ToString(dr["DEFAULTDES"])
}
);
}
}
catch (Exception ex)
{
SaveError_Log("Employee", "Setup", ex.Message);
}
return Json(Designationlist, JsonRequestBehavior.AllowGet);
}


and now the grid was displaying as shown below image without header.
20911

kindly provide me some suggestion, and let me know what i had done wrong in it.

RCN
Feb 11, 2015, 5:27 AM
In the morning i am gonna review it.

RCN
Feb 11, 2015, 5:42 AM
Please post a complete (but simplified) code sample demonstrating how to reproduce the issue.

Some more details are in our forums guidelines.
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)
More Information Required (http://forums.ext.net/showthread.php?10205)

RCN
Feb 11, 2015, 5:46 AM
By running your code


@(Html.X().GridPanel()
.ID("GPDesignation")
.Width(1158)
.Height(260)
.Header(true)
.Store(Html.X().Store()
.PageSize(10)
.ID("SDesignation")
.Model(Html.X().Model()
.Fields(
new ModelField("ROLE_CODE", ModelFieldType.String),
new ModelField("ROLE_DESC", ModelFieldType.String),
new ModelField("DESIGNATION_CODE", ModelFieldType.String),
new ModelField("DESIGNATION_DESC", ModelFieldType.String),
new ModelField("DEFAULT_DESIG", ModelFieldType.String)
)
)
)
.ColumnModel(
Html.X().Column().Text("Role").DataIndex("ROLE_CODE").Width(150),
Html.X().Column().Text("Role Description").DataIndex("ROLE_DESC").Width(326),
Html.X().Column().Text("Designation").DataIndex("DESIGNATION_CODE").Width(250),
Html.X().Column().Text("DSG Description").DataIndex("DESIGNATION_DESC").Width(326),
Html.X().Column().Text("Default").DataIndex("DEFAULT_DESIG").Width(100)
)
.SelectionModel(Html.X().RowSelectionModel())
)


I get the following result
20931

sundarsureshin
Feb 11, 2015, 7:36 AM
But for me it displays as shown below, even after loading with or without data.
20941

RCN
Feb 11, 2015, 11:42 AM
Sundarsureshin, it would be easier to identify the issue if you post a full sample.

sundarsureshin
Feb 11, 2015, 12:28 PM
RCN, i have posted it fully on #5 (http://forums.ext.net/showthread.php?53741-Grid-panel-header-was-not-displaying&p=247671&viewfull=1#post247671) only thing i missed out is the json result function, by default on page load i dont see header for that gridpanel.



var BindDestination= function (EMP_CODE) {

$.ajax({
url: '@Url.Action("Bind_Destination", "Setup")',
type: 'post',
data: { EMP_CODE: EMP_CODE },
success: function (data) {
var grid = Ext.getCmp("GPDesignation");
grid.getStore().loadData(data);
}
});
};

RCN
Feb 11, 2015, 4:17 PM
Grid works as expected:

21031



@(Html.X().GridPanel()
.ID("GPDesignation")
.Width(1158)
.Height(260)
.Header(true)
.Store(Html.X().Store()
.PageSize(10)
.ID("SDesignation")
.Proxy(Html.X().AjaxProxy().Url(Url.Action("Bind_Destination")).Reader(Html.X().JsonReader().RootProperty("data")))
.Model
(Html.X().Model()
.Fields(new ModelField("ROLE_CODE", ModelFieldType.String),
new ModelField("ROLE_DESC", ModelFieldType.String),
new ModelField("DESIGNATION_CODE", ModelFieldType.String),
new ModelField("DESIGNATION_DESC", ModelFieldType.String),
new ModelField("DEFAULT_DESIG", ModelFieldType.String))))
.ColumnModel(Html.X().Column().Text("Role").DataIndex("ROLE_CODE").Width(150),
Html.X().Column().Text("Role Description").DataIndex("ROLE_DESC").Width(326),
Html.X().Column().Text("Designation").DataIndex("DESIGNATION_CODE").Width(250),
Html.X().Column().Text("DSG Description").DataIndex("DESIGNATION_DESC").Width(326),
Html.X().Column().Text("Default").DataIndex("DEFAULT_DESIG").Width(100))
.SelectionModel(Html.X().RowSelectionModel())
)




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

public StoreResult Bind_Destination()
{
List<Designation_Model> lst = new List<Designation_Model>();

for (int index = 0; index < 15; index++)
{
lst.Add(new Designation_Model
{
ROLE_CODE = index.ToString(),
ROLE_DESC = string.Format("ROLE_DESC - {0}", index),
DESIGNATION_CODE = string.Format("DESIGNATION_CODE - {0}", index),
DESIGNATION_DESC = string.Format("DESIGNATION_CODE - {0}", index),
DEFAULT_DESIG = string.Format("DEFAULT_DESIG - {0}", index)
});
}

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

public class Designation_Model
{
public string ROLE_CODE { get; set; }
public string ROLE_DESC { get; set; }
public string DESIGNATION_CODE { get; set; }
public string DESIGNATION_DESC { get; set; }
public string DEFAULT_DESIG { get; set; }
}
}

RCN
Feb 11, 2015, 4:27 PM
Sundarsureshin, there are other controls in your view that may be affecting GridPanel.

21041

In addition, please provide a running example. In the example provided by you, some classes are missing, it connects to database, etc.

By @Geoffrey.Mcgill:


If we cannot copy+paste your code sample directly into a test project, and run without having to fix unnecessary exceptions, your chances of receiving timely support are diminished.

sundarsureshin
Feb 12, 2015, 12:59 PM
Thank you RCN, i will check on this.

RCN
Feb 12, 2015, 1:06 PM
Please keep us posted.

sundarsureshin
Feb 12, 2015, 1:28 PM
Sure, will do.