I want to show all fields of a certain ListItem. This includes LookUpFields and ChoiceFields. But I only seem to be able to show Textfields, like Title. How can I show all fields of my ListItem?
The problem is that I get an error when I try to show other fields of a listitem the way I got 'Title' to show, as if the strings I type in don't exist as fields in that listitem. But they do exist and are populated with values!
What is good way to show custom fields of a listitem without getting ObjectReference errors?
Also I get this error: The given key was not present in the dictionary.
private void foo()
{
using (ClientContext context = new ClientContext(ApplicationContext.Current.Url))
{
_list = context.Web.Lists.GetByTitle("MyList").Title);
_items = _list.GetItems(CamlQuery.CreateAllItemsQuery());
context.Load(_items);
context.ExecuteQueryAsync(
new ClientRequestSucceededEventHandler(OnListItemsRequestSucceeded),
new ClientRequestFailedEventHandler(OnListItemsRequestFailed));
}
}
private void OnListItemsRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
{
// this is not called on the UI thread
Dispatcher.BeginInvoke(ShowListItemDetails);
}
public void ShowListItemDetails()
{
foreach (ListItem i in _items)
{
TextBox_Details.Text += i["Title"].ToString() + Environment.NewLine;
// Now the rest of the fields of this item.
}
}
Edit: What also is a big problem is I cant get the debugger working. This code is running as a Silverlight webpart on a local Sharepoint site. I attach the debugger to the iexplorer.exe but it won't break.
If I could get the debugger to work it would be a great help indeed.
you have tell the query what all fields you need to pull from lists
CamlQuery camlQuery = new CamlQuery();
camlQuery.ListItemCollectionPosition = itemPosition;
camlQuery.ViewXml =
#"<View>
<ViewFields>
<FieldRef Name='Title'/>
<FieldRef Name='Category'/>
<FieldRef Name='Estimate'/>
</ViewFields>
<RowLimit>10</RowLimit>
</View>";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
for more details
http://msdn.microsoft.com/en-us/library/ee857094.aspx#SP2010ClientOM_Accessing_Large_Lists
To get item properties you will need to specify all the item properties you need in the second parameter of the ClientContext.Load method
e.g
string server = "http://localhost";
ClientContext context = new ClientContext(server);
Web web = context.Web;
var spList = web.Lists.GetByTitle("MyTitle");
CamlQuery query = new CamlQuery();
var items = spList.GetItems(query);
context.Load(items,
itema => itema.Include(
item => item,
item => item["ComplexProperty"]));
context.ExecuteQuery();`
Related
I'm trying set the text in my listView to the string value in my FavJokes class.
class FavJokes {
var index: Int? = null
var string: String? = null
}
When ever a user favorites a joke, I create a FavObject instance and assign it values for the index(as the Jokes are stored in an array) and the string value of the joke.
val newFav = FavJokes()
newFav.index = primaFreeze!!
newFav.string = ("${questionProvider.quesRegistry[primaFreeze!!]}... ${answerProvider.ansRegistry[primaFreeze!!]}")
favorites.add(newFav)
When I try to use this array of FavJoke objects as the datasource for my listView what I see is my project id and ".FavJokes#ee8e3e" show up on the listView itself.
I don't think I should populate the listView with just the string value for the joke because for my setOnItemClick{} method, the view I segue to is going to need the index of the joke in order to populate the textView with the correct joke.
I'm new to kotlin/Java started learning it about 3 days ago, but I do have some Swift experience. In Swift I could use an IndexPath object to get/set the values for my tableView. Is there such an object or a method that I can access and set the TextView.text values in Kotlin/Java?
In Android you set an adapter on the list view and then add a setOnItemClickListener, which when called will be provided with the index of the item in the list.
One the simplest adapters is an ArrayAdapter.
Here is a tutorial from a familiar source.
And here is a quick example from some existing code.
in OnCreateView I get my list view.
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
val rootView = inflater!!.inflate(R.layout.fragment_target_selection, container, false)
targetList = rootView.findViewById(R.id.names_list) as ListView
return rootView
}
then in my onResume I receive an array of objects which I then use to create my adapter.
disposables.add(telescopeInterface.namesListStream.subscribe {
println("here is the names list")
namesList = it
namesListAdapter = ArrayAdapter(this.context, android.R.layout.simple_list_item_1, namesList?.names)
println("setting up list view with the updated list")
setupListView()
})
then in the setupListView() I assign the adapter to the list view and add a listener.
private fun setupListView() {
namesListAdapter?.let { targetList.adapter = it }
targetList.setOnItemClickListener { adapterView, view, i, l ->
targetSelectionListenter?.targetSelected()
val entry = adapterView.getItemAtPosition(i)
println("item $entry")
telescopeInterface.sendSelectedTarget(entry as DSOCatalogNameEntry)
}
}
The full object remains in the list, the adapter is just used to select what is displayed in the list view, then you get the index of the selection, which you then use to extract the full object from your source list.
Problem
On one Form I have a Multilist where each item has a "name" and an "ID number". I'd like my app to do the following:
After I select an item, it will go to the "profile" screen and then it will display all the information about that person, based on the "ID number" that I will get from the Storage.
Question
How can I get the information from the Multilist item I just clicked?
And then, how can I save that info so I can use it in the "before show (Profile screen)" so I can retrieve the info from Storage.
Thnaks
I will suggest you use a MultiButton instead of Multilist, then you can add actionEvent to individual element.
You can save individual element into static variables in the actionEvent and use it in the before show of your profile form. For example:
Declare this globally:
private static String UserName = "";
And initialize it as follows:
Container content = new Container(new BoxLayout(BoxLayout.Y_AXIS));
content.setScrollableY(true);
for (int i = 0; i < YourItemsLength; i++) {
final MultiButton mb = new MultiButton("Blablabla");
mb.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent evt) {
UserName = mb.getTextLine1(); // or anything you want it to be
//show the profile form here
}
});
content.addComponent(mb);
}
content.revalidate();
In the beforeShow() of profile, call UserName and you should be able to use the value. Do the same for all the values you need.
I totally agree with Diamonds answer and I think that's the best/simplest way to create a list of items. However, if you do still want to use MultiList you need to implement a ListModel or use DefaultListModel.
From your question I assume you just used the MultiList and filled out the values?
In that case when there is an action event on the list you can just get the instance of the list the invoke Map m = (Map)myList.getSelectedItem();
The map should return key/value pairs containing your data. You can have hidden keys within that data simple by naming them differently from rendererd list elements so you can have something like "id" as the key.
I have a strange problem here. We develop a Windows 10 Universal App and now I want to update my listview when I add new value. But unfortunately it wont work and I dont really know why. When I add new value it won't update my list view.
The data comes from a background-thread (REST-Request against Server) and therefore I know, I should use something that runs the "add-functionality" on the UI-Thread.
First of all I declared a IProgress and my collection:
private List<dtoGemeinde> _listeGemeinden = new List<dtoGemeinde>();
public List<dtoGemeinde> GemeindenCollection
{
get { return this._listeGemeinden; }
}
IProgress<dtoGemeinde> prog;
prog = new Progress<dtoGemeinde>(UpdateListViewUI);
This is the "UpdateListViewUI" method:
public void UpdateListViewUI(dtoGemeinde dto)
{
_listeGemeinden.Add(dto);
this.listViewGemeinden.ItemsSource = GemeindenCollection;
}
And this is the callback method which is called when the background thread, which loads the data from the server, is finished:
public async void onCallBackGemeinden(List<dtoGemeinde> listeGemeinden)
{
if (listeGemeinden != null && listeGemeinden.Count > 0)
{
this.progress.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
foreach (dtoGemeinde dto in listeGemeinden)
{
await listViewGemeinden.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => prog.Report(dto));
}
}
else
{
await new MessageDialog("Data cant be load", "Error").ShowAsync();
}
}
ObservableCollection instead of List usually works fine if need to bind a ListView and be able to see the updates, if this doesn't work any underlying class might need to implement the INotifyChanged pattern to update any properties within the collection if needed.
I have a ListView inside of a Popup control (seems to be significant that it's in a Popup). The coded test is pretty basic, click a ToggleButton to open the popup, and then select an item in the ListView.
Except it seems that it can't find the item in the ListView.
System.ArgumentException: No row was specified as search container for
the control. To search for a cell control using 'ColumnIndex', you
must specify row as a container element or add 'RowIndex' to the
search property of the cell. Parameter name: SearchProperties Result
StackTrace: at
Microsoft.VisualStudio.TestTools.UITesting.ALUtility.ThrowDataGridRelatedException(String
errorString, String propertyName) at
Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfCell.GetUITestControlsForSearch()
at
Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_QueryId()
at
Microsoft.VisualStudio.TestTools.UITesting.UITestControlSearchArgument.get_SingleQueryString()
at
Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean
useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList`1
windowTitles, Int32& timeLeft)
The generated code is failing at this point
uIItemCell.Checked = this.MyListBoxCellParams.UIItemCellChecked;
where uIItemCell comes from this property
public WpfCell UIItemCell
{
get
{
if ((this.mUIItemCell == null))
{
this.mUIItemCell = new WpfCell(this);
#region Search Criteria
this.mUIItemCell.SearchProperties[WpfCell.PropertyNames.ColumnHeader] = null;
this.mUIItemCell.SearchProperties[WpfCell.PropertyNames.ColumnIndex] = "1";
this.mUIItemCell.WindowTitles.Add("CodedUITestWindow");
#endregion
}
return this.mUIItemCell;
}
}
So I guess this is where the criteria should be specified, but what how? And should row be hard coded somehow? Why didn't the test editor set the row?
If it helps, this is the .ctor where UIItemCell (above) is specified, seems like more search params
public UIMyCellDataItem(UITestControl searchLimitContainer) :
base(searchLimitContainer)
{
#region Search Criteria
this.SearchProperties[UITestControl.PropertyNames.ControlType] = "DataItem";
this.SearchProperties["HelpText"] = "MyCell's helptext property, this is correctly specified, but the HelpText is used only as a tooltip";
this.WindowTitles.Add("CodedUITestWindow");
#endregion
}
Thanks
I've normally seen ListView treated as a List, and the items as ListItem. You might want to use inspect.exe or the UI Test Builder to look at the properties. You can try to manually code the control. Sorry for posting speculation as an answer. Too long to be a comment.
WpfWindow PopUpWindow = new WpfWindow();
PopUpWindow.SearchProperties[WpfWindow.PropertyNames.Name] = "Pop Up Window Name";
WpfList List = new WpfList(PopUpWindow);
List.SearchProperties[WpfList.PropertyNames.Name] = "List Name";
WpfListItem ItemToSelect = new WpfListItem(List);
ItemToSelect.SearchProperties[WpfListItem.PropertyNames.Name] = "List Item Name";
// Click button to activate pop up window
ItemToSelect.Select();
// Creating the controls.
WpfWindow mainWindow = new WpfWindow();
// Add search properties.
WpfTable table = new WpfTable(mainWindow);
// Add search properties
WpfRow row = new WpfRow(table);
// Add search properties.
WpfCell cell = new WpfCell(row);
// Add search properties.
// Just adding the table and row as containers.
row.Container = table;
cell.Container = row;
}
I am building a WPF application that takes in rows of data, and outputs them into different tabs in the GUI based on the data contained in the row. However, the tabs aren't known until runtime, so I need to dynamically build an unknown number of tabs with collection views with different filters off of my main ObservableCollection.
The problem I have been running in to is that using ListCollectionViews I need a predicate filter but I do not know of a way to have a dynamic predicate based on a local variable? I tried variable capturing, but that just changes all of my filters each time a new tab is added.
//class variables
string currTab;
public ObservableCollection<MyData> myCollection = new ObservableCollection<myData>();
private void DataAdd(object sender, RoutedEventArgs e)
{
currTab = inputData.ToString();
ListCollectionView c = new ListCollectionView(myCollection);
c.Filter = new Predicate<object>(MyFilter);
}
public bool MyFilter(object foo)
{
if (foo).ToString() != currTab)
return false;
else
return true;
}
I also tried using lambda expressions and with ICollectionView, but the collection doesn't update with new values, so I just see empty tabs.
CollectionView c = new CollectionViewSource { Source = myCollection.Where(z => z.ToString() == tabName) }.View;
Is there a way to make either of these approaches work? Or a better way to do this?
it turns out I just needed to use a local variable for the predicate
var b = currTab
c.Filter = (foo) =>{return foo.ToString() == b;};