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

Cannot add more than 4 letters in new row

5 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nemo
Top achievements
Rank 1
Nemo asked on 31 Jul 2012, 06:42 PM
Hi,

I am trying to add a new row to RadGridView. I can add new row, BUT It doesn't allow me to enter more than 4letters in the new row. Could you check this and let me know what went wrong?

Attached screenshot.

Thank you,
-Prathibha

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Aug 2012, 06:42 AM
Hi,

 May I ask you to provide a little bit more information on how are your GridViewColumns defined, especially the first column where you can enter just 4 letters? 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Nemo
Top achievements
Rank 1
answered on 02 Aug 2012, 08:41 PM

I am using MVVMLight(MvvmLightCommand) to convert event to command.

If I want to change the name of the customer or add a new customer, I can only type 4 letters in the firstName and lastName columns (eg: “asdf”) after 4th letter all text I typed are ignored.

This is my code:

 

View

<telerik:RadGridView ItemsSource="{Binding CustomerCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"

                    AutoGenerateColumns="False" Margin="5 5 5 5"

                    AlternationCount="2" CanUserInsertRows="True" ShowInsertRow="True"

                                      Background="LightBlue" Name="TelerikDGrid">

<i:Interaction.Triggers>

             <i:EventTrigger EventName="AddingNewDataItem">

                  <MvvmLightCommand:EventToCommand Command="{Binding Path=AddNewCustomerCommand}" PassEventArgsToCommand="True" />

             </i:EventTrigger>

</i:Interaction.Triggers>

<telerik:RadGridView.Columns>

<telerik:GridViewMaskedTextBoxColumn Header="FistName" DataMemberBinding="{Binding FirstName}" />

<telerik:GridViewMaskedTextBoxColumn Header="LastName" DataMemberBinding="{Binding LastName}" />



CustomerClass


 public class Customer : ViewModel.ViewModelBase

    {

        string firstName;

        public string FirstName //Product

        {

            get { return firstName; }

            set { firstName = value; NotifyPropertyChanged("FirstName"); }

        }

        string lastName;

        public string LastName //Name

        {

            get { return lastName; }

            set { lastName = value;NotifyPropertyChanged("LastName "); }

        }

        bool hasEmail;

        public bool HasEmail

        {

            get { return hasEmail; }

            set { hasEmail = value;NotifyPropertyChanged("HasEmail"); }

        }

        bool hasPhone;

        public bool HasPhone

        {

            get { return hasPhone; }

            set { hasPhone = value; NotifyPropertyChanged("HasPhone");}

        }

       

    }

}

ViewModel


ObservableCollection<Customer> customerCollection = new ObservableCollection<Customer>();

        public ObservableCollection<Customer> CustomerCollection

        {

            get { return customerCollection; }

            set { customerCollection = value; NotifyPropertyChanged("CustomerCollection"); }

        }

#region Constructor

public ViewModel()

{

AddNewCustomerCommand = new RelayCommand(Execute_AddNewCustomerCommand, CanExecute_AddNewCustomerCommand);

}

#endregion

#region AddNewCustomerCommand

public ICommand AddNewCustomerCommand { get; private set; }

public void Execute_AddNewCustomerCommand(object e)

        {

            Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs args = (Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs)e;

            args.NewObject = new Customer();

        }

  public bool CanExecute_AddNewCustomerCommand(object parameter)

        {

            return true;

        }

#endregion

Thank you,
-Prathibha

0
Dimitrina
Telerik team
answered on 03 Aug 2012, 08:05 AM
Hello,

 I would suggest you to use GridViewDataColumn instead. May I ask you is there a special reason to use GridViewMaskedTextBoxColumn?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Nemo
Top achievements
Rank 1
answered on 03 Aug 2012, 06:39 PM
Hi Didie,

I wanted to use GridViewMaskedTextBoxColumn for the look and feel(the GridViewMaskedTextBoxColumn looks non-editable but allow the user edit it when clicked on the TextBoxColumn) . I also wanted to make the FirstColumn(FirstName) read only, but allow the user to add new row.(ie user cannot edit existing columns.Allow the user to add new row and add attributes,but once he commit the change by enter key, that column should be ReadOnly.)

Thank you,
-Prathibha


0
Accepted
Pavel Pavlov
Telerik team
answered on 08 Aug 2012, 08:55 AM
Hi,

As Didie mentioned - GridViewDataColumn is the good choice for your case - By default it displays a TextBlock , and when being edited it would display a TextBox.

Regarding your second question - you can prevent the "old" rows from entering edit mode the following way :

1. Subscribe to the RadGridView.BeginningEdit event
2. Inside the event handler check if it is old or new row
3. In case it is an "old" row set e.Cancel = true .

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Nemo
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Nemo
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or