I have a grid populated dinamicaly with several columns including a textbox a combo box and a button.
Initally the button and the combo are disabled.
What I need to happen is when I right something in the textbox the button and the combo on the same row to be enabled.
I atached to the TextInputStart of the textbox a function where i try to get from there to the row parent and acces the other columns but it doesn't seam to work as I get null.
THIS IS WHERE I GET NULL
Anyway I am not sure if I get the parent row if it would help.
Any other ideas, or any ideas?:)
Thanks a lot,
Alex
7 Answers, 1 is accepted
You may use the extension methods - ChildrenOfType<> and ParentOfType<>. Thus, the implementation of the TextInputStart event may look like:
private void txtCalc_TextInputStart(object sender, TextCompositionEventArgs e)
{
TextBox textBox = sender as TextBox;
GridViewRow parentRow = textBox.ParentOfType<
GridViewRow
>();
RadComboBox combo = parentRow.ChildrenOfType<
RadComboBox
>().FirstOrDefault();
RadButton button = parentRow.ChildrenOfType<
RadButton
>().FirstOrDefault();
if (combo != null && button != null)
{
combo.IsEnabled = true;
button.IsEnabled = true;
}
}
You may take a look at this blog post for further reference.
Kind regards,
Maya
the Telerik team
That worked great.
Thanks,
Alex
Is there anyway I can implement this using Commands instead of actions?
From what I know the command defualt trigger is click but I need it to be key up. Is this possible?How?
Thanks a lot,
Alex
Unfortunately, I am not quite sure what is your exact requirement. Do you want to create a command handling the enabling/disabling of some elements/ cells ? So, in order to provide you with an appropriate answer, I would need a bit more information about your scenario.
Maya
the Telerik team
What I need to do is the following:
The scenario is the same as the first post , I have a RadGridView with some columns. Among them a button textbox, a checkbox and a dropdown. The button , the dropdown are disabled.
When I write something inside the textbox the button and the dropdown should be enabled(only for the specific row)
What is changed now is that I have to use MVVM and commands instead of KeyUp event of the textbox.
Somehow I managed to find a piece of code that helps me trigger the event of KeyUp using commands.
This helped
http://www.telerik.com/community/forums/silverlight/gridview/using-image-control-in-grid-to-delete-row-instead-of-button-using-mvvm.aspx
My problem now is how to acces form inside de ViewModel the button and the dropdown from the same row,
let's say inside
public void MyMethod from the example (among last posts)
Thanks,
Alex
The basic idea behind the Model-View-ViewModel Design Pattern is to separate the view from the data, using the ViewModel. Thus, following up your requirements, it will be beyond that concept to make the ViewModel aware of the visual elements in the application. So, I would recommend you to use the approach demonstrated above, handling the TextInputStart event.
Maya
the Telerik team
Please let me know
How can I get the value of TextBox present inside the row of RadGridView using MVVM ? I need to insert the particular value in the database in ViewModel.
The property value is binded with the TextBox value if it is present outside the RadGridView but when placed inside RadGridView ,the property value for the TextBox is becoming null.
Thanks in advance