none
Silverlight Data Grid

    Question

  • I have a DATA grid + dataform in a page. the data is coming from oracle table from the bkend. inside dataform I have a combobox which is having data from database view. I want to establish master details r/ship b/w

    (dataform)combobox and datagrid

    Please help.

    Wednesday, February 22, 2012 8:59 PM

Answers

  • you must select your data from model , for example:

    var pizzas = from p in context.Pizzas select p;

    dataGrid1.ItemsSource = pizzas;

     

    context is a reference to your entities container. If you do not know what its name for your mdel, juist double-click on it and choose open with and select XML viewer. Then, find the following line in a storage models section:

     

    <EntityContainer Name="PizzatonModelStoreContainer">

     


    Name is your entities context`s name, so:

     

    private PizzatonModelStoreContainer context = new PizzatonModelStoreContainer();

    Eventually, your code will look like this:

     

    public partial class PizzasPage : Page
        {
    
            private PizzatonModelStoreContainer context = new PizzatonModelStoreContainer();
    
            public PizzasPage()
            {
                InitializeComponent();
                Loaded += new RoutedEventHandler(OnPizzasPageLoaded);
            }
    
            void OnPizzasPageLoaded(object sender, RoutedEventArgs e)
            {
                var pizzas = from p in context.Pizzas select p;
                pizzasGrid.ItemsSource = products.Entities;
            }
    }

     

     

    Thursday, February 23, 2012 2:20 PM
  • thanks Sagaman! excellent I like your answer but I have something like this.

                            Datagrid                                            DataForm

    Datagrid data is coming from oracle table

    column1| column2|column3| column4| column5|       Column1(txbox)

                                                                                |        Column2(txbox table data)

                                                                                |        Column3(txbox table data)

                                                                                         Column4(txtbox table data)

                                                                                  Column5(combobox view) I retrieve this data from view but unable to                                                                            do two way binding with datagrid.

    Do I have to establish r/ship between combobox view and datagrid table in order to get two way binding ????

    In another page I have table data in grid and form so I can go back n forth with silverlight editable pencil control. (its two way binding)

                                                                    

    Thursday, February 23, 2012 2:56 PM

All replies

  • How to establish r/ship between table and view in edmx.designer ???

    Any one please help...

    Thursday, February 23, 2012 10:46 AM
  • you must select your data from model , for example:

    var pizzas = from p in context.Pizzas select p;

    dataGrid1.ItemsSource = pizzas;

     

    context is a reference to your entities container. If you do not know what its name for your mdel, juist double-click on it and choose open with and select XML viewer. Then, find the following line in a storage models section:

     

    <EntityContainer Name="PizzatonModelStoreContainer">

     


    Name is your entities context`s name, so:

     

    private PizzatonModelStoreContainer context = new PizzatonModelStoreContainer();

    Eventually, your code will look like this:

     

    public partial class PizzasPage : Page
        {
    
            private PizzatonModelStoreContainer context = new PizzatonModelStoreContainer();
    
            public PizzasPage()
            {
                InitializeComponent();
                Loaded += new RoutedEventHandler(OnPizzasPageLoaded);
            }
    
            void OnPizzasPageLoaded(object sender, RoutedEventArgs e)
            {
                var pizzas = from p in context.Pizzas select p;
                pizzasGrid.ItemsSource = products.Entities;
            }
    }

     

     

    Thursday, February 23, 2012 2:20 PM
  • I spend one complete day to figure out how to dispaly silverlight datagrid summary columns still no idea. I am using SL5+ER4 + Domain datasource.  (I don't know how long it will take to finished products like Telrik for silverlight ppl). Its annoying sometimes.

      Col1 | Col2 | Col3 | Col4     | Col_Total

                                                     

              1        2        3         4           11

              5        6        7         8           26

    =================================

    Total : 6        8        10      blah       blah

    =================================  

    I have already went to various blogs and tried this.----------->


    DataColumn sumCol;
    sumCol = new DataColumn("Total", typeof(double));
    sumCol.Expression = "ColumnA + ColumnB + ColumnC + ColumnD";
    ds.Tables["TableName"].Columns.Add(sumCol);


    IEnumerable<AllocationLine> list = allocationLineDataGrid.ItemsSource.OfType<AllocationLine>();
    decimal Total = list.Sum(p => (decimal)p.GetType().GetProperty("/*Amount*/").GetValue(p, null));

    Anyy one having the same problem ?

    Thnks.

    Thursday, February 23, 2012 2:54 PM
  • thanks Sagaman! excellent I like your answer but I have something like this.

                            Datagrid                                            DataForm

    Datagrid data is coming from oracle table

    column1| column2|column3| column4| column5|       Column1(txbox)

                                                                                |        Column2(txbox table data)

                                                                                |        Column3(txbox table data)

                                                                                         Column4(txtbox table data)

                                                                                  Column5(combobox view) I retrieve this data from view but unable to                                                                            do two way binding with datagrid.

    Do I have to establish r/ship between combobox view and datagrid table in order to get two way binding ????

    In another page I have table data in grid and form so I can go back n forth with silverlight editable pencil control. (its two way binding)

                                                                    

    Thursday, February 23, 2012 2:56 PM
  • heh, so, have you solved your problem?

    Friday, February 24, 2012 9:13 AM
  • I have solved the problem

    In the backend I join the view to the table column.

    view and table column is same with different types but I manage to maintain the same as int32.

    Thank you for everything

    Friday, February 24, 2012 11:25 AM
  •  Page

    Friday, February 24, 2012 3:13 PM
  • oipho

    Friday, February 24, 2012 4:26 PM
  • Hi

    You can Achieve this in both ways

    By Setting the DisplayIndex Property 

    See the list of available Properties of DataGridTextColumn

    http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridtextcolumn_properties(v=vs.95).aspx

    Friday, February 24, 2012 10:08 PM
  • u9h

    Thursday, March 01, 2012 4:10 PM
  • Thanks for your reply sriram

    Do you have any sample code for programatically creating hyperlink which should be display as 4th column in silverlight 5 datagrid business application ?

    Friday, March 02, 2012 7:09 PM
  • childwindow cw = new childwindow()

    win.show() doesn't work here in sl5 b.applicaiton.

    =============================================

    I showed like this

    create child window page childy

    then

    childwindow cw= childy();

    cw.show();

    Friday, March 02, 2012 7:11 PM
  • Thanks for the reply scott.

    The problem is I have hyperlinkbutton column in silverlight datagrid in master dg , when user click it should display details associated records. of that master datagrid in child window.

    trying from last 3 days...

    what to write and where ?

    Thank you

    Please help me give me a related example.

    Monday, March 05, 2012 2:50 PM
  • Hi

    Is Your Problem Resolved?? 

    Wednesday, March 14, 2012 12:32 AM
  • Yes ,Sriram I solved my problem. Now my next task is how to get glassy buttons(without any Exp.blend) and set child window theme in SL5

    Also I have a write code to show an autocompletebox from the backend table (dynamically)

    +

    how to replace a textbox with multiline textbox in dataform ? I refer to customDataform.cs but no help. still looking for new ideas....

    ====================================================================================

    I am just searching everywhere how to implement autocomplete box dynamically>?????

    so I have a table which is link to another table I have to show another table column in my autocompletebox.

     <sdk:AutoCompleteBox Grid.Row="2" Grid.Column="1" Height="23" HorizontalAlignment="Stretch" Margin="10,6,5,0"
                           ItemsSource="{Binding Path=Entity.ProjNme}"
                          IsTextCompletionEnabled="True" Name="autoCompleteBox1" VerticalAlignment="Top" Loaded="AutoComplete_Loaded" />

    already ref these blogs but no help....

    http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx

    http://www.silverlight.net/learn/creating-ui/control-basics/silverlight-toolkit-autocompletebox

    Programmaticalyl or xaml ????

    Thank you

    Thursday, March 15, 2012 1:45 PM