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

[Solved] Binding in the Grid

0 Answers 141 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Parameswari
Top achievements
Rank 2
Parameswari asked on 22 Jun 2011, 06:29 AM
   Hi ,
This is Parameswari. Iam Building a Application for Accounting using MVVM . I have a table(say, Info)  which contains information of two data (say, Contains info abt Invoice & Quote). I have to filter the two datas & present in  two seperate grid. 
    So I created views for  filtering two datas. Iam able to do all above . Probelm is : When I doubleClick the row in the grid , the Quote Or Invoice Form of that particular ID should be opened & we have to allow the user for Edit operation. I have sent my view and viewmodel coding. In the view, ItemSource is binded to the view created for Quote Or Invoice . SelectedItem is binded to the Info Table( CurrentInvoice is type of InfoTable)
    In the viewmodel when i doubleClick on the gridrow IF part of the Edit is not checked ,it directly enters ELSE part . If i Bind the itemsource with the InfoTable Entityset then iam able to view the form, the problem here is ,it lists all the information of the table (ie Quote & Invoice) ,but I want either invoice or Quote. Transreference is used check whether it is invoice or quote.

Pls help me in this part.
Thank U

ViewModel:
  
  
  public ICommand EditCommand
        {
            get
            {
                return new DelegateCommand<object>(EditInvoice);
            }
        }
  
     public void EditInvoice(object obj)
        
        {
             
            if (CurrentInvoice != null)
            {
                if (TransReference == 3)
                {
                     
                    addMode = false;
                    objRadWindow = new RadWindow();
                    newQuote = new View.Invoice.Quote(this);
                    objRadWindow.Content = newQuote;
                    objRadWindow.WindowState = WindowState.Maximized;
                    //objRadWindow.Header = "Quote";
                    objRadWindow.Show();
                }
  
  
                else if (TransReference == 4)
                {
                    addMode = false;
                    objRadWindow = new RadWindow();
                    newInvocie = new View.Invoice.Invoice(this);
  
                    objRadWindow.Content = newInvocie;
                    objRadWindow.WindowState = WindowState.Maximized;
                    objRadWindow.Header = "Invoice";
                    objRadWindow.Show();
                }
            }
  
            else
                MessageBox.Show("Please select a customer to view", App.ApplicationTitle, MessageBoxButton.OK);
            }
  
         
View: 
ItemsSource="{Binding Path=InvoiceListingViews, Mode=TwoWay}"                                         
                                     SelectedItem="{Binding Path=CurrentInvoice, Mode=TwoWay}"                               
                                     ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto">
           
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="RowActivated">
                    <i:InvokeCommandAction Command="{Binding EditCommand}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <telerikGridView:RadGridView.Background>
                <ImageBrush ImageSource="{Binding Source={StaticResource iconviewmodel}, Path=GridLines}" Stretch="None"  AlignmentX="Left" AlignmentY="Top"/>
            </telerikGridView:RadGridView.Background>
            <telerikGridView:RadGridView.Columns >
                <telerikGridView:GridViewDataColumn Header="Type" Width="75" DataMemberBinding="{Binding TransactionName}"/>
                <telerikGridView:GridViewDataColumn Header="Date" Width="74" DataMemberBinding="{Binding TransactionDateTime}" DataFormatString = "{}{0:MM/dd/yyyy}" />
                <telerikGridView:GridViewDataColumn Header="No." Width="30" DataMemberBinding="{Binding SalesHeaderID}"/>
                <telerikGridView:GridViewDataColumn Header="Customer Name" Width="2*" DataMemberBinding="{Binding CustomerName}"/>
                <telerikGridView:GridViewDataColumn Header="Phone" Width="1*" DataMemberBinding="{Binding PhoneNumber, Converter={StaticResource phoneformat}}"/>
                <telerikGridView:GridViewDataColumn Header="Due Date" Width="74" DataMemberBinding="{Binding DueDate}" DataFormatString = "{}{0:MM/dd/yyyy}"/>
                <telerikGridView:GridViewDataColumn Header="Total Price" Width="1*" DataMemberBinding="{Binding TotalAmount}" TextAlignment="Right" DataFormatString = "{}{0:c2}" />
                <telerikGridView:GridViewDataColumn Header="Balance" Width="1*" DataMemberBinding="{Binding Balance}" TextAlignment="Right" DataFormatString = "{}{0:c2}"/>
                <telerikGridView:GridViewDataColumn Header="Currency" Width="1*" DataMemberBinding="{Binding CurrencyDescription}"/>
                <telerikGridView:GridViewDataColumn Header="Total Price(USD)" Width="1*" DataMemberBinding="{Binding TotalAmountCurrency}" TextAlignment="Right" DataFormatString = "{}{0:c2}"/>
            </telerikGridView:RadGridView.Columns>
        </telerikGridView:RadGridView>
Tags
GridView
Asked by
Parameswari
Top achievements
Rank 2
Share this question
or