PDA

View Full Version : [ADDED] [V0.8.2] ServerMapping



Timothy
Sep 13, 2009, 2:37 PM
Hello,

I was wondering if the SVN users could get an early preview implementation of the ServerMapping feature for the Store control. I'm working on a large application that uses enterprise mapping layers where I do not want to implement data transfer objects for presentation layer functions.

Would it be possible at this point to implement some basic ServerMapping functions?

Cheers as always,
Timothy

Vladimir
Sep 14, 2009, 12:01 PM
Hi,

Added. Please update from SVN and test

Here is my test case


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

<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
Store1.DataSource = Employee.GetAll();
Store1.DataBind();
}

public class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public Department Department { get; set; }

public static List<Employee> GetAll()
{
return new List<Employee>
{
new Employee
{
ID = 1,
Name = "Nancy",
Surname = "Davolio",
Department = Department.GetAll()[0]
},
new Employee
{
ID = 2,
Name = "Andrew",
Surname = "Fuller",
Department = Department.GetAll()[2]
}
};
}
}

public class Department
{
public int ID { get; set; }
public string Name { get; set; }

public static List<Department> GetAll()
{
return new List<Department>
{
new Department {ID = 1, Name = "Department A"},
new Department {ID = 2, Name = "Department B"},
new Department {ID = 3, Name = "Department C"}
};
}
}


</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Coolite Toolkit Example - Server Mapping</title>
<link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />

<ext:Store ID="Store1" runat="server">
<Reader>
<ext:JsonReader ReaderID="ID">
<Fields>
<ext:RecordField Name="ID" Type="Int" />
<ext:RecordField Name="Name" />
<ext:RecordField Name="Surname" />
<ext:RecordField Name="Department" ServerMapping="Department.Name" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>

<ext:GridPanel ID="GridPanel1" EnableViewState="true" AutoHeight="true" runat="server"
StoreID="Store1" Title="List" Icon="Application">
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column Header="ID" Sortable="true" DataIndex="ID" />
<ext:Column Header="NAME" Sortable="true" DataIndex="Name" />
<ext:Column Header="SURNAME" Sortable="true" DataIndex="Surname" />
<ext:Column DataIndex="Department" Header="Department" Width="240"/>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
</SelectionModel>
<LoadMask Msg="Loading" ShowMask="true" />
</ext:GridPanel>
</form>
</body>
</html>

Timothy
Sep 15, 2009, 1:09 PM
Thanks vladimir,

You're the best! This will definitely make life easier :)

Cheers,
Timothy