RadComboBox with Checkbox enabled - Persists last selected item text - telerik

I have developed a user control which has only a RadComboBox with checkbox enabled in it. The problem that I am facing in my pages is, whenever I deselect all the checkbox items with in the RadComboBox and on close of it, the last selected item is displayed in its text section. I am not finding a way to fix it.
In the ideal scenario, if nothing / everything is selected, I am defaulting to the text "All". If any item is selected, the item text is displayed. Can some one help me, if I have to do any specific check to fix this problem?
I am sharing a animated GIF for my issue below.
Thanks,
Sriram

I also got the same issue. But I solved as following.
Creative a property in your userControl as:
public string OnClientItemChecked {
set { ddlControID.OnClientItemChecked = value; }
}
on aspx:
<uc1:TagName ID="ddlControlID" runat="server" OnClientItemChecked="ClearValue" />
on script tag:
function ClearValue(sender, eventArgs) {
var combobox = sender;
var value = combobox._checkedIndices.toString();
if (value == "") {
combobox.clearSelection();
combobox.set_emptyMessage(combobox.get_emptyMessage());
}
}

on aspx:
Do AllowCustomText="True" in your RadComboBox.

Related

Windows Form Listview is not visually showing selected items

We have a tool that is being integrated into our application. We have some strict borders around us too in that we cannot modify the application except for our extensions. I have searched here, I've searched the internet, but cannot find any postings about this problem.
I have a Windows Form that contains a ListView and our user requires we create a checkbox to Select/Deselect all. I have the event handler for when the check box state changes and call the routine to set everything to Selected.
private void SelectAllEventHandler(object sender, EventArgs e)
{
ChangeState(RadCapListView, SelectAllRadcap.Checked);
}
private void ChangeState(SWF.ListView control, bool state)
{
if (control.CheckBoxes)
{
control.Items.OfType<SWF.ListViewItem>().ToList()
.ForEach(item => item.Checked = state);
}
else
{
control.Items.OfType<SWF.ListViewItem>().ToList()
.ForEach(item => item.Selected = state);
}
control.Refresh();
}
Going into debug mode all items are marked as selected.
Also at the control level SelectedItems is properly updated.
The issue is that visually the control just will not highlight the selected items like we have our WPF forms doing. As you can see in the code I also tried to refresh the control hoping that would show items selected, but no joy.
Has anyone solved this problem in getting selected items to display properly?
Thank!
Instead of using control.Refresh(), try control.Focus().

Janus 2 GridEx disable a Button in a given cell

There isn't much support with Janus, thats why i'm asking you for help.
I have a gridEx with 3 columns(INT ID, String MARKET, Button DELETE). when you add an item to the grid you only have to add the ID and MARKET, the button DELETE is automatically created and enabled.
What i want is for the element with ID=5 the button of that row must be disabled.
the data of the gridEx has a DataSource but is only binded with ID and MARKET.
the Data configuration of the GridEx Designer of the cell button DELETE the Bound is False and it hasn't got any DataMember.
What i have is the element wiht ID=5 but i don't know how to programatically disable the cell Button of that element in the grid.
Any clue of how to accomplish this issue???
Thanks!!
You have to utilize the FormattingRow event of the grid.
This is a sample code:
private void grdex_FormattingRow(object sender, RowLoadEventArgs e)
{
if (e.Row.RowType == Janus.Windows.GridEX.RowType.Record)
if (Convert.ToInt32(e.Row.Cells["ID"].Value) == 5)
e.Row.Cells["DELETE"].ButtonEnabled = false;
}

Windows Phone 7: How to notify data is updated in ListBox?

I have above scenario: If user click on ListBox, it will either have sub items (again ListBox) or detail view.
So what i did currently is: Whenever user clicks any item, made a web call and filled up the same ListBox if clicked item is having further sub items.
Now, issue comes in picture:
Suppose i am in 4th screen (detail view),
Moved to the 3rd and 2nd screen with data maintained as stack (Its working fine, yes i am maintaining data in ObservableCollection<ObservableCollection<MyObjects>> so while moving back, i am fetching data from there)
Now, if i click any item in screen 2, it will open detail view for the screen 3 ListBox data.
Means that ListBox is not getting notified that we have filled data inside OnBackKeyPress()
FYI, i am filling up ListBox and WebBrowser in the same page., so my problem is that how do i notify ListBox once i filled up data from stack which i have maintained?
Yes i have also implemented INotifyPropertyChanged but don't know why its not working.
Please check my code:
ListBox and WebView screen: http://pastebin.com/K1G27Yji
RootPageItem class file with the implementation of INotifyPropertyChanged: http://pastebin.com/E0uqLtVG
sorry for pasting code in above way, i did as question is being long.
Problem:
How do i notify ListBox that data is changed from OnBackKeyPress?
And what is the behavior if you set:
listBox1.ItemsSource = null;
before
listBox1.ItemsSource = listRootPageItems;
This is just wrong architecture. Instead of reloading the same listbox, please add a single page for each screen. Share data between them inside the App class (internal static) and use the built in navigation stack for handling "going back". Don't override OnBackKeyPress for this purpose.
You will get your desired functionality for "free" with easier to maintain and use codebase.
Oops it was a silly mistake i made.
I forgot to set items[] array inside OnBackKeyPress() but was accessing while clicking item, hence its having items[] data of last step we moved in forward direction, it was executing the same data.
Now, i have just included a single line and it has solved my problem.
items = listRootPageItems.ToArray(); // resolution point
So final code of onBackKeyPress() is:
/**
* While moving back, taking data from stack and displayed inside the same ListBox
* */
protected override void OnBackKeyPress(CancelEventArgs e)
{
listBox1.Visibility = Visibility.Visible;
webBrowser1.Visibility = Visibility.Collapsed;
listBox1.SelectedIndex = -1;
if (dataStack.Count != 0)
{
listBox1.ItemsSource = null;
listRootPageItems = dataStack[dataStack.Count-1];
listBox1.ItemsSource = listRootPageItems;
items = listRootPageItems.ToArray(); // resolution point
dataStack.Remove(listRootPageItems);
e.Cancel = true;
}
}

WP7 : Populating a ListBox depending on the input from another ListBox

I'm trying to add ListItems to a ListBox (ListBox3) depending on the selectedItem of another ListBox (ListBox1). The problem is , The Items aren't added to the Listbox.
Here's the code :
private void createlist()
{
if (listBox1.SelectedValue.ToString().Equals("EPL"))
{
ListBoxItem manchesterunited = new ListBoxItem();
manchesterunited.Content = "Manchester United";
listBox3.Items.Add(manchesterunited);
}
}
private void listBox1_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
createlist();
}
createlist() does the changes and is called in the SelctionChanged() event of ListBox1.
New to C# and WP7 programming , any help will be much appreciated.
Create the lists in your viewmodel and bind the listbox to a list<> in your viewmodel say SelectedList. When the user selects the item from ListBox1 just change the value of SelectedList with the appropriate List and Notify the property changed event. And it will be done.!
i think you program not run in mvvm structure.
make sure your logic is right. you can make a breakpoint at the line
ListBoxItem manchesterunited = new ListBoxItem();
Ensure run those code in if code block.
the way add a control in a listbox is correct.

No text in textbox on save

View:
TextBox x:Name="feedback" Text="{Binding FeedbackText,Mode=TwoWay}"
ViewModel:
public string FeedbackText
{
get
{
return _feedbackTextProperty;
}
set
{
_feedbackTextProperty = value;
RaisePropertyChanged(FeedbackTextPropertyName);
}
}
I am using a bindable application bar but when I click the button there is no value in the FeedbackText property. It looks as if "lostfocus" is not firing to update the property.
I am using MVVM Light. Have I missed something?
If you still had focus in the textbox when you clicked the app bar button the textbox won't fire the lost focus event and cause teh binding to update.
Yes, this can be frustrating. :(
There are various work arounds such as forcibly updating the binding in such a situation or the Binding Helper in the Coding4Fun Tools.
I hope that I am not too late. I had the same problem using Window Phone 8 saving the TextBox text when pressing an ApplicationBarIconButton. A way to fix this issue is to update the binding source property of the focused TextBox. You can do that with the following code:
var focusedObject = FocusManager.GetFocusedElement() as TextBox;
if (focusedObject != null)
{
var binding = focusedObject.GetBindingExpression(TextBox.TextProperty);
if (binding != null)
{
binding.UpdateSource();
}
}
Best!

Resources