How add text in dynamic columns

8 posts, 0 answers
  1. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 16 Dec 2010 Link to this post

    Hi

    I am using TreeListView.
    I am adding columns dynamically.
    How to acees the Row Cells to put value.
    or how to add data to the dynamically generated coulms.

    I want to manupulate the values before displaying in Row.

    Thanks.
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 17 Dec 2010 Link to this post

    Hello Sharada,

    You do not add data to the columns or cells. Your business object should feed the new column.


    Actually the common way to add dynamic columns follows the pattern below:

    GridViewDataColumn col1=new GridViewDataColumn();
    col1.Header="Column1";
    col1.DataMemberBinding=new Binding("CustomProperty1");
    ....
    this.radTreeListView1.Columns.Add(col1);

    However if you need to access the autogenerated columns you may use AutoGeneratingColumn event, please read more about this here.

    Greetings,
    Vanya Pavlova
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jorge
    Jorge avatar
    4 posts
    Member since:
    Mar 2011

    Posted 23 Mar 2011 Link to this post

    Hello Vanya,

    I'm having the same issue here. I cannot do the Binding because the objects I'd like to show on the table can have a variant number (and thus names) of the properties.

    So, what I'm trying to do, is to create this treeListView dinamycally, and I get to create all the columns I need. But then, I need to populate it with all the data from the objects. How can I do that without doing any binding?

    Thank you very much,
    Jorge
  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 23 Mar 2011 Link to this post

    Hi Jorge,

     
    May you provide some more details on the topic ? How the RadTreeListView is bound to in your case?
    As the RadTreeListView supports binding to a DataTable, you may give it a try.

    Greetings,
    Vanya Pavlova
    the Telerik team
  6. Jorge
    Jorge avatar
    4 posts
    Member since:
    Mar 2011

    Posted 23 Mar 2011 Link to this post

    Hello Vanya,

    Thank you for your quick response.

    What I'm trying to do here is to display some properties of a set of objects into a TreeListView, so that user of my app can filter and search through them. But those objects will not be always the same: Their parameters to display will vary depending on some user input, so I cannot know beforehand which parameters I will need to display. That is why I cannot bind my TreeListView to any object, because I don't know beforehand which features this object should have.

    What I was trying to do is to create a table dinamically. I got to create the set of columns fine, but I didn't know how to add rows and then fill the colmns content with the parameter's values.

    I'll do some readings on this DataTable class you mention to see if this can suit my needs.

    Thank you very much.
  7. Jorge
    Jorge avatar
    4 posts
    Member since:
    Mar 2011

    Posted 24 Mar 2011 Link to this post

    I got to do what I needed by using a DataTable, thank you very much Vanya.

    I'm having a little trouble now, though.

    I've binded a RowSelected event to mi TreeListView. Whenever this event is fired, my event handler function executes ok, but right after executing this function, an exception is thrown saying something like: The column '.' does not belong to the table 'TableName' (the datatable I bound to the TreeListView).

    Is this a known bug? am I doing anything wrong?

    This is what I'm doing to create the table:

    DataTable table = new DataTable("GeometryProperties");
     
    //Columns creation
    for (int i = 1; i < ShowObject[0].Attributes.parameters.Count + 1; i++)
                    {
     
                        string name = ShowObject[0].Attributes.parameters[i - 1].NAME;
     
                        /*DataColumn c = new DataColumn();
                        c.DataType = System.Type.GetType("System.String");
                        c.ColumnName = name;
                        c.AutoIncrement = false;
                        c.Caption = name;
                        c.ReadOnly = false;
                        c.Unique = false;
                        // Add the column to the table.
                        table.Columns.Add(c);
                    }
     
    //Rows creation
    for (int j = 0; j < ShowObject.Count; j++)
                    {
                        DataRow row = table.NewRow();
                        row["Geometry ID"] = ShowObject[j].Geometry.FID;
     
                        for (int k = 0; k < ShowObject[j].Attributes.parameters.Count; k++)
                        {
     
                            row[ShowObject[j].Attributes.parameters[k].NAME] = ShowObject[j].Attributes.parameters[k].VALUE;
                        }
     
                        table.Rows.Add(row);
                    }
     
    //Binding
    this.radTreeListView.ItemsSource = table;
     
    No parameter I'm setting as column name is named '.', so why might the TreeListView look for a '.' column on the table?

    Should I open a new discussion topic for this issue?
  8. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 24 Mar 2011 Link to this post

    Hello Jorge,

     
    May you verify which RadTreeListView's event you are currently using? RowLoaded, SelectionChanged or maybe I am missing something? I have spent some time researching such error types and I found that its is better to access the columns by indexes, when you are creating rows, rather that by name, you may get more information about this here. Using this snippet we are not able to reproduce this exception, I believe that the best option is to send us a small application in a new support ticket which we can use for local debugging.


    Greetings,
    Vanya Pavlova
    the Telerik team
  9. Jorge
    Jorge avatar
    4 posts
    Member since:
    Mar 2011

    Posted 25 Mar 2011 Link to this post

    Hello Vanya,

    I got to solve my problem by eliminating an incorrect binding in the XAML file I didn't know I had. Sorry for having bothered you with this problem.

    Thanks again for the DataTable tip, it worked great!!
Back to Top
UI for WPF is Visual Studio 2017 Ready