This is a migrated thread and some comments may be shown as answers.

My First Grid

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Iron
Iron
Vincent asked on 01 Apr 2016, 01:21 PM

Hi from France,

I came from old Infragistics software version (7x) and now i'm the last in my society to work on new project with telerik software.

recently i use, splitter,dock and tiles with no problem.

But now I'm using for the first time a grid, a hierachical grid.

before use my sql table (idRubrique,libelle,iOrdre,idRubriqueParent,...)

i prefert test how it's work with simulate datatable, because when i was getting sql table i need to modify data before bind it.

This is my sample to create grid hierarchical content, and i don't know why i don't see my last child (t3) on grid.

If someone can open my eyes ? Thanks ! (excuse me for my bad english)

The code behind: 

Dim t1 As New System.Data.DataTable
        t1.Columns.Add("idRubrique")
        t1.Columns.Add("idRubriqueParent")
        t1.Columns.Add("DEPENSES")
        t1.Columns.Add("BilanAcquisition")
        t1.Columns.Add("ESTIMEES")

        Dim r As Data.DataRow

        r = t1.NewRow
        r.ItemArray = {1, 0, "FONCIER", "TEST", Nothing}
        t1.Rows.Add(r)

        r = t1.NewRow
        r.ItemArray = {2, 0, "VRD", Nothing, Nothing}
        t1.Rows.Add(r)

        Dim t2 As New System.Data.DataTable
        t2.Columns.Add("idRubrique")
        t2.Columns.Add("idRubriqueParent")
        t2.Columns.Add("DEPENSES")
        t2.Columns.Add("BILANACQUISITION")
        t2.Columns.Add("ESTIMEES")

        r = t2.NewRow
        r.ItemArray = {1, 1, "Acquisition", Nothing, Nothing}
        t2.Rows.Add(r)

        r = t2.NewRow
        r.ItemArray = {2, 1, "Frais de Notaire", Nothing, Nothing}
        t2.Rows.Add(r)

        r = t2.NewRow
        r.ItemArray = {3, 1, "Archeologie", Nothing, Nothing}
        t2.Rows.Add(r)

        Dim t3 As New System.Data.DataTable
        t3.Columns.Add("idRubrique")
        t3.Columns.Add("idRubriqueParent")
        t3.Columns.Add("DEPENSES")
        t3.Columns.Add("BILANACQUISITION")
        t3.Columns.Add("ESTIMEES")

        r = t3.NewRow
        r.ItemArray = {1, 1, "Frais liés à la négociation foncière", Nothing, Nothing}
        t3.Rows.Add(r)

        r = t3.NewRow
        r.ItemArray = {2, 1, "Aquisition Terrain", Nothing, Nothing}
        t3.Rows.Add(r)

        r = t3.NewRow
        r.ItemArray = {3, 1, "Commission d'acquisition", Nothing, Nothing}
        t3.Rows.Add(r)

        RadGrid1.MasterTableView.DataSource = t1
        RadGrid1.MasterTableView.DataKeyNames = New String() {"idRubrique"}

        'LV2
        Dim tableViewOrders As New Telerik.Web.UI.GridTableView(RadGrid1)
        tableViewOrders.DataSource = t2
        tableViewOrders.DataKeyNames = New String() {"idRubrique"}

        Dim relationFields As Telerik.Web.UI.GridRelationFields = New Telerik.Web.UI.GridRelationFields()
        relationFields.MasterKeyField = "idRubrique"
        relationFields.DetailKeyField = "idRubriqueParent"
        tableViewOrders.ParentTableRelation.Add(relationFields)
        RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders)

        'LV3
        Dim tableViewOrders2 As New Telerik.Web.UI.GridTableView(RadGrid1)
        tableViewOrders2.DataSource = t3
        tableViewOrders2.DataKeyNames = New String() {"idRubrique"}

        Dim relationFields2 As Telerik.Web.UI.GridRelationFields = New Telerik.Web.UI.GridRelationFields()
        relationFields2.MasterKeyField = "idRubrique"
        relationFields2.DetailKeyField = "idRubriqueParent"
        tableViewOrders2.ParentTableRelation.Add(relationFields2)
        tableViewOrders.DetailTables.Add(tableViewOrders2)

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 06 Apr 2016, 06:02 AM
Hello Vincent,

Please make sure that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Programmatic Data Binding
(NeedDataSource and DetailTableDataBind event)


You should set the DataSource property only within these event handlers.

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Vincent
Top achievements
Rank 1
Iron
Iron
answered on 08 Apr 2016, 08:21 AM

Thanks for your, help.

After my first test, now it's very difficult to released wanted project result ...

I'm made screen to explain "simply" because since many days i'm stuck.

I get data from SQL BDD and i transforme it in vb.net to generate a datatable.

SQL Keys Parent/Child :

Primary Key : idInitRubrique
Child Key : idInitRubriqueParent

During my treatment, if i see a "codeDynamique" (example here "OSVRD"), I complete the "libelle" column, and their the "idKey" column.
I generate and complete datatable with other columns.

Now i've got :
 a composed primary key : idInitRubrique / idKey
 Child Composed Key : idInitRubriqueParent / idInitRubriqueParentKey

And i'm doing a Self Hierachical grid, from my code behind (just added RadGrid to aspx file)
with yellow editable zone directly in grid (in place)
All parents in "Estimees" column must have sum of children

Please help me :-(

0
Eyup
Telerik team
answered on 13 Apr 2016, 07:22 AM
Hi Vincent,

I am afraid self-hierarchy is not supported with RadGrid. You can check the RadTreeList control instead:
http://demos.telerik.com/aspnet-ajax/treelist/examples/overview/defaultcs.aspx

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Vincent
Top achievements
Rank 1
Iron
Iron
Answers by
Eyup
Telerik team
Vincent
Top achievements
Rank 1
Iron
Iron
Share this question
or