Hi,
I need to create a grid which is very similar to the demo Grid in Hierarchy
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx
Since this for a mock up demo, i don't have any database to point out.
I followed this example http://www.telerik.com/community/forums/aspnet-ajax/grid/show-columns-without-datasource.aspx to create a single level grid.
Could you please tel me , what is the best way to create a hierarchy grid datasource with out a database.
Need help ASAP.
Thanks.
Eva
I need to create a grid which is very similar to the demo Grid in Hierarchy
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/threelevel/defaultcs.aspx
Since this for a mock up demo, i don't have any database to point out.
I followed this example http://www.telerik.com/community/forums/aspnet-ajax/grid/show-columns-without-datasource.aspx to create a single level grid.
Could you please tel me , what is the best way to create a hierarchy grid datasource with out a database.
Need help ASAP.
Thanks.
Eva
2 Answers, 1 is accepted
0
Naunton
Top achievements
Rank 1
answered on 30 Dec 2010, 03:17 AM
Hi Eva, try this ..
This is the sample of Autogenerate Hierarchy from Demo that I have learned last 2 weeks, but now the page does not work.
Hope this will help you.
This is the sample of Autogenerate Hierarchy from Demo that I have learned last 2 weeks, but now the page does not work.
Hope this will help you.
Public
Function
BindingDataset()
As
DataSet
Dim
dataset
As
New
DataSet()
'////////////////////////////////////////Customers Table//////////////////////////////////////////////////////////////////
Dim
dataTable
As
New
DataTable()
dataTable.TableName =
"Customers"
dataTable.Columns.Add(
"CustomerID"
)
dataTable.Columns.Add(
"Country"
)
dataTable.Columns.Add(
"City"
)
dataTable.Columns.Add(
"CompanyName"
)
dataTable.Columns.Add(
"ContactName"
)
dataTable.Columns.Add(
"TotalOrders"
,
GetType
(system.
Double
))
dataTable.Columns.Add(
"TotalAmount"
,
GetType
(system.
Double
))
'dim keys(2) as DataColumn
'keys(0) = dataTable.Columns("CustomerID")
'dataTable.PrimaryKey = keys
dataset.Tables.Add(dataTable)
dataTable.Rows.Add(
New
Object
() {
"SEVES"
,
"UK"
,
"London"
,
"Seven Seas Imports"
,
"Hari Kumar"
, 26, 17170.1501083374})
dataTable.Rows.Add(
New
Object
() {
"OLDWO"
,
"USA"
,
"Anchorage"
,
"Old World Delicatessen"
,
"Rene Phillips"
, 24, 16323.5498657227})
dataTable.Rows.Add(
New
Object
() {
"FRANS"
,
"Italy"
,
"Torino"
,
"Franchi S.p.A."
,
"Paolo Accorti"
, 10, 1545.69999885559})
dataTable.Rows.Add(
New
Object
() {
"MAGAA"
,
"Italy"
,
"Bergamo"
,
"Magazzini Alimentari Riuniti"
,
"Giovanni Rovelli"
, 21, 7602.79999160767})
dataTable.Rows.Add(
New
Object
() {
"SIMOB"
,
"Denmark"
,
"Kobenhavn"
,
"Simons bistro"
,
"Jytte Petersen"
, 15, 18136.3499946594})
dataTable.Rows.Add(
New
Object
() {
"LAZYK"
,
"USA"
,
"Walla Walla"
,
"Lazy K Kountry Store"
,
"John Steel"
, 2, 357})
dataTable.Rows.Add(
New
Object
() {
"CHOPS"
,
"Switzerland"
,
"Bern"
,
"Chop-suey Chinese"
,
"Yang Wang"
, 22, 12884.999961853})
dataTable.Rows.Add(
New
Object
() {
"ERNSH"
,
"Austria"
,
"Graz"
,
"Ernst Handel"
,
"Roland Mendel"
, 102, 113229.730472565})
dataTable.Rows.Add(
New
Object
() {
"FRANK"
,
"Germany"
,
"M?nchen"
,
"Frankenversand"
,
"Peter Franken"
, 48, 28719.5600280762})
dataTable.Rows.Add(
New
Object
() {
"HILAA"
,
"Venezuela"
,
"San Crist?bal"
,
"HILARION-Abastos"
,
"Carlos Hern?ndez"
, 45, 23610.0800743103})
dataTable.Rows.Add(
New
Object
() {
"CENTC"
,
"Mexico"
,
"M?xico D.F."
,
"Centro comercial Moctezuma"
,
"Francisco Chang"
, 2, 100.799999237061})
dataTable.Rows.Add(
New
Object
() {
"GOURL"
,
"Brazil"
,
"Campinas"
,
"Gourmet Lanchonetes"
,
"Andr? Fonseca"
, 19, 8700.92997741699})
dataTable.Rows.Add(
New
Object
() {
"BLONP"
,
"France"
,
"Strasbourg"
,
"Blondel p?re et fils"
,
"Fr?d?rique Citeaux"
, 26, 19087.2500305176})
dataTable.Rows.Add(
New
Object
() {
"THEBI"
,
"USA"
,
"Portland"
,
"The Big Cheese"
,
"Liz Nixon"
, 7, 3361})
'////////////////////////////////////////Orders Table//////////////////////////////////////////////////////////////////
dataTable =
New
DataTable()
dataTable.TableName =
"Orders"
dataTable.Columns.Add(
"OrderID"
)
dataTable.Columns.Add(
"CustomerID"
)
dataTable.Columns.Add(
"ShipName"
)
dataTable.Columns.Add(
"ShipCity"
)
dataTable.Columns.Add(
"ShipCountry"
)
dataTable.Columns.Add(
"EmployeeID"
)
'keys(0) = new DataColumn
'keys(0) = dataTable.Columns("OrderID")
'dataTable.PrimaryKey = keys
dataset.Tables.Add(dataTable)
dataTable.Rows.Add(
New
Object
() {1,
"SEVES"
,
"Richter Supermarkt"
,
"Sofia"
,
"Bulgaria"
, 1})
dataTable.Rows.Add(
New
Object
() {2,
"SEVES"
,
"Wellington Importadora"
,
"Bern"
,
"Germany"
, 2})
dataTable.Rows.Add(
New
Object
() {3,
"OLDWO"
,
"Que Del?cia"
,
"Paris"
,
"France"
, 3})
dataTable.Rows.Add(
New
Object
() {4,
"FRANK"
,
"Tortuga Restaurante"
,
"M?nchen"
,
"Germany"
, 4})
dataTable.Rows.Add(
New
Object
() {5,
"OLDWO"
,
"Romero y tomillo"
,
"Lisabon"
,
"Portugal"
, 5})
dataTable.Rows.Add(
New
Object
() {6,
"LAZYK"
,
"Ricardo Adocicados"
,
"Copenhagen"
,
"Denmark"
, 6})
dataTable.Rows.Add(
New
Object
() {7,
"BLONP"
,
"Reggiani Caseifici"
,
"Moscow"
,
"Russia"
, 7})
dataTable.Rows.Add(
New
Object
() {8,
"ERNSH"
,
"Que Del?cia"
,
"San Crist?bal"
,
"Venezuela"
, 8})
dataTable.Rows.Add(
New
Object
() {9,
"ERNSH"
,
"Die Wandernde Kuh"
,
"Graz"
,
"Austria"
, 9})
dataTable.Rows.Add(
New
Object
() {10,
"Frans"
,
"Die Wandernde Kuh"
,
"Viena"
,
"Austria"
, 10})
'////////////////////////////////////////Employees Table//////////////////////////////////////////////////////////////////
dataTable =
New
DataTable(
"Employees"
)
dataTable.Columns.Add(
"EmployeeID"
)
dataTable.Columns.Add(
"LastName"
)
dataTable.Columns.Add(
"FirstName"
)
dataTable.Columns.Add(
"Title"
)
dataTable.Columns.Add(
"BirthDate"
)
dataTable.Columns.Add(
"Country"
)
'keys(0) = new DataColumn
'keys(0) = dataTable.Columns("EmployeeID")
'dataTable.PrimaryKey = keys
dataset.Tables.Add(dataTable)
dataTable.Rows.Add(
New
Object
() {1,
"Avilon"
,
"Nancy"
,
"Sales Representative"
,
"12/8/1948 12:00:00 AM"
,
"USA"
})
dataTable.Rows.Add(
New
Object
() {2,
"Leverling"
,
"Janet"
,
"Sales Representative"
,
"12/5/1968 12:00:00 AM"
,
"USA"
})
dataTable.Rows.Add(
New
Object
() {3,
"Peacock"
,
"Margaret"
,
"Sales Representative"
,
"2/8/1988 12:00:00 AM"
,
"USA"
})
dataTable.Rows.Add(
New
Object
() {4,
"Buchanan"
,
"Steven"
,
"President"
,
"1/8/1953 12:00:00 AM"
,
"USA"
})
dataTable.Rows.Add(
New
Object
() {5,
"Suyama"
,
"Michael"
,
"Vice President"
,
"12/8/1956 12:00:00 AM"
,
"UK"
})
dataTable.Rows.Add(
New
Object
() {6,
"King"
,
"Robert"
,
"Sales Representative"
,
"3/9/1978 12:00:00 AM"
,
"UK"
})
dataTable.Rows.Add(
New
Object
() {7,
"Callahan"
,
"Laura"
,
"Sales Representative"
,
"9/1/1980 12:00:00 AM"
,
"UK"
})
dataTable.Rows.Add(
New
Object
() {8,
"Dodsworth"
,
"Anne"
,
"Sales Representative"
,
"3/18/1968 12:00:00 AM"
,
"Spain"
})
dataTable.Rows.Add(
New
Object
() {9,
"Fuller"
,
"Andrew"
,
"Sales Representative"
,
"4/8/1981 12:00:00 AM"
,
"Austria"
})
dataTable.Rows.Add(
New
Object
() {10,
"Smith"
,
"John"
,
"President"
,
"6/9/1980 12:00:00 AM"
,
"Bulgaria"
})
'////////////////////////////////////////OrderDetails Table//////////////////////////////////////////////////////////////////
dataTable =
New
DataTable(
"OrderDetails"
)
dataTable.Columns.Add(
"OrderID"
)
dataTable.Columns.Add(
"ProductID"
)
dataTable.Columns.Add(
"Quantity"
)
dataTable.Columns.Add(
"UnitPrice"
)
'keys(1) = new DataColumn
'keys(0) = dataTable.Columns("OrderID")
'keys(1) = dataTable.Columns("ProductID")
'dataTable.PrimaryKey = keys
dataset.Tables.Add(dataTable)
dataTable.Rows.Add(
New
Object
() {1, 2, 15, 7})
dataTable.Rows.Add(
New
Object
() {2, 1, 50, 7})
dataTable.Rows.Add(
New
Object
() {3, 3, 60, 23})
dataTable.Rows.Add(
New
Object
() {3, 5, 80, 4})
dataTable.Rows.Add(
New
Object
() {5, 6, 10, 31})
dataTable.Rows.Add(
New
Object
() {7, 7, 10, 25})
dataTable.Rows.Add(
New
Object
() {8, 8, 10, 15})
dataTable.Rows.Add(
New
Object
() {9, 9, 8, 12})
dataTable.Rows.Add(
New
Object
() {10, 4, 8, 12})
'////////////////////////////////////////Products Table//////////////////////////////////////////////////////////////////
dataTable =
New
DataTable(
"Products"
)
dataTable.Columns.Add(
"ProductID"
)
dataTable.Columns.Add(
"ProductName"
)
dataTable.Columns.Add(
"QuantityPerUnit"
)
dataTable.Columns.Add(
"UnitsOnStock"
)
'redim keys(0)
'keys(0) = dataTable.Columns("ProductID")
'dataTable.PrimaryKey = keys
dataset.Tables.Add(dataTable)
dataTable.Rows.Add(
New
Object
() {1,
"Chai"
,
"10 boxes x 20 bags"
, 45})
dataTable.Rows.Add(
New
Object
() {2,
"Chang"
,
"24 - 12 oz bottles"
, 34})
dataTable.Rows.Add(
New
Object
() {3,
"Aniseed Syrup"
,
"12 - 550 ml bottles"
, 61})
dataTable.Rows.Add(
New
Object
() {4,
"Cheese cake"
,
"12 packages"
, 36})
dataTable.Rows.Add(
New
Object
() {5,
"Chef Anton's Cajun Seasoning"
,
"48 - 6 oz jars"
, 80})
dataTable.Rows.Add(
New
Object
() {6,
"Chef Anton's Gumbo Mix"
,
"36 boxes"
, 78})
dataTable.Rows.Add(
New
Object
() {7,
"Grandma's Boysenberry Spread"
,
"12 - 8 oz jars"
, 91})
dataTable.Rows.Add(
New
Object
() {8,
"Northwoods Cranberry Sauce"
,
"12 - 12 oz jars"
, 123})
dataTable.Rows.Add(
New
Object
() {9,
"Mishi Kobe Niku"
,
"18 - 500 g pkgs."
, 54})
Dim
CustomersOrdersRelation
As
DataRelation
CustomersOrdersRelation =
New
DataRelation(
"CustomersOrders"
, dataset.Tables(
"Customers"
).Columns(
"CustomerID"
), dataset.Tables(
"Orders"
).Columns(
"CustomerID"
))
Dim
OrdersEmployees
As
DataRelation
OrdersEmployees =
New
DataRelation(
"OrdersEmployees"
, dataset.Tables(
"Orders"
).Columns(
"EmployeeID"
), dataset.Tables(
"Employees"
).Columns(
"EmployeeID"
))
Dim
OrdersOrderDetails
As
DataRelation
OrdersOrderDetails =
New
DataRelation(
"OrdersOrderDetails"
, dataset.Tables(
"Orders"
).Columns(
"OrderID"
), dataset.Tables(
"OrderDetails"
).Columns(
"OrderID"
))
Dim
OrderDetailsProducts
As
DataRelation
OrderDetailsProducts =
New
DataRelation(
"OrderDetailsProducts"
, dataset.Tables(
"OrderDetails"
).Columns(
"ProductID"
), dataset.Tables(
"Products"
).Columns(
"ProductID"
))
dataset.Relations.Add(CustomersOrdersRelation)
dataset.Relations.Add(OrdersEmployees)
dataset.Relations.Add(OrdersOrderDetails)
dataset.Relations.Add(OrderDetailsProducts)
Return
dataset
End
Function
Protected
Sub
RadGrid1_NeedDataSource(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
RadGrid1.NeedDataSource
radgrid1.DataSource=BindingDataset()
End
Sub
0
Eva
Top achievements
Rank 1
answered on 31 Dec 2010, 12:50 AM
Thank you so much. You saved my day.