Edward
Aug 29, 2010, 11:33 AM
Hi,
If you have used dynamic data or know something about it, you probably know how powerful it could be. Things like a strong 'separation of concerns' should not be taken lightly.
Anyway I hope after this build in support for Dynamic Data is not far away ! :cool:
In the mean while I created an basic ext.js example (based on the example of Matt Berseth found here (http://mattberseth.com/blog/2008/09/dynamic_data_experimenting_wit.html).
You have to create a dynamic data website first and add a store and a grid. Paging and sorting is not (yet) added.
// just call this in the onload of the dynamic data/page templates/List.aspx
public void ApplyDynamicDataToStoreAndGrid()
{
var columns =
from c in table.Columns
where c.Scaffold // can add other attributes criteria
orderby c.SortExpression
select c;
var ColumnPrimKey =
(from c in table.Columns
where c.IsPrimaryKey
select c).First();
JsonReader reader = new JsonReader();
if (ColumnPrimKey != null)
{
reader.IDProperty = ColumnPrimKey.Name;
}
Store1.Reader.Add(reader);
ColumnModel columnModel = new ColumnModel();
foreach (var c in columns)
{
var rf = new RecordField()
{
Name=c.Name
};
reader.Fields.Add(rf);
var gridColumn = new Column()
{
ColumnID = c.Name,
DataIndex = c.Name,
Header = c.ShortDisplayName
};
GridPanel1.ColumnModel.Columns.Add(gridColumn);
}
}
If you have used dynamic data or know something about it, you probably know how powerful it could be. Things like a strong 'separation of concerns' should not be taken lightly.
Anyway I hope after this build in support for Dynamic Data is not far away ! :cool:
In the mean while I created an basic ext.js example (based on the example of Matt Berseth found here (http://mattberseth.com/blog/2008/09/dynamic_data_experimenting_wit.html).
You have to create a dynamic data website first and add a store and a grid. Paging and sorting is not (yet) added.
// just call this in the onload of the dynamic data/page templates/List.aspx
public void ApplyDynamicDataToStoreAndGrid()
{
var columns =
from c in table.Columns
where c.Scaffold // can add other attributes criteria
orderby c.SortExpression
select c;
var ColumnPrimKey =
(from c in table.Columns
where c.IsPrimaryKey
select c).First();
JsonReader reader = new JsonReader();
if (ColumnPrimKey != null)
{
reader.IDProperty = ColumnPrimKey.Name;
}
Store1.Reader.Add(reader);
ColumnModel columnModel = new ColumnModel();
foreach (var c in columns)
{
var rf = new RecordField()
{
Name=c.Name
};
reader.Fields.Add(rf);
var gridColumn = new Column()
{
ColumnID = c.Name,
DataIndex = c.Name,
Header = c.ShortDisplayName
};
GridPanel1.ColumnModel.Columns.Add(gridColumn);
}
}