Set ID item listview from database - android-listview

I need to display a list of events in a listview, I want to do is that the ID of an item of listview is the ID that is registered in my DB. It is posible?

I would recommend you create a custom list adapter that takes in a custom object modeled around your database.
Do some research on BaseAdapter.
Once you've created your custom list adapter you can store all your database rows into something like
ArrayList<CustomObject> co = new ArrayList<CustomObject>();
Then when an OnClickListener is fired you can use the position like so:
int id = co.get(position).getId();
Assuming of course your CustomObject has a method called getId().

Related

Pass parameter to virtual entity data provider plugin

I'm aiming to show virtual entity records on a subgrid on the form of a custom entity (say, Client). I have created a virtual entity, custom data provider and registered the required plugin. So far things work fine; I load the form, subgrid loads with the data from external webservice.
Now, I want to pass a string field on the form (say, Client.ExternalId) as a parameter to the retrieveMultiple plugin so that I can use this field to query the datasource.
The retriveMultiple plugin steps (registered automatically when custom data provider was set up) show that it was registered on the virtual entity and not Client entity. Since it gets executed on load of the subgrid on the Client entity form I am not sure how I can pass a field to the plugin.
Can someone please give some guidance on how to achieve this?
Version 1710 (9.2.22103.194) online
Thanks
If the virtual entity has an N:1 relationship with the main entity and the subgrid is configured to show related records, then you can do like this:
// first, get the whole query
var query = context.InputParameterOrDefault<QueryExpression>("Query");
// next, get the linkEntity and then the linkFilter
var linkFilter = query.LinkEntities.FirstOrDefault(x => x.LinkToEntityName == "mainEntityLogicalName").LinkCriteria;
// next, get the main entity id
var mainEntityId = linkFilter.Conditions.FirstOrDefault(x => x.AttributeName == "mainEntityIdFieldName").Values.FirstOrDefault() as Guid?;
// finally, retreive main entity to get the Client.ExternalId
var mainEntity = orgSvc.Retrieve("mainEntityLogicalName", mainEntityId.Value, new ColumnSet("Client.ExternalId"));
var clientExternalId = mainEntity.GetAttributeValue<string>("Client.ExternalId");

How to find items in a ListView

I created a new Recipe form that presents users with a list of ~20 items to choose from by adding a numeric quantity to TextField in each Row. The ingredients are presented in an scrolling ListView. Each item(ingredient) is a Row that includes a TextField and a Text with the ingredient name.
I need to access items in a ListView. I need to find items where the user has inputted data in the TextFields when the Save Button has been pushed. I'm new to Flutter and don't want to create a hack because I don't understand best practices.
First of make pojo class for your data to display on listview.
for example your listview containg list of userdata..
Future<UserData> userDataList;
// then check listview data value..
userDataList.then((userData){
if(userData.title=="OK") // here check user input data.
print(userData.title);
});
UserData class is pojo class it conting getter setter methods...

Get Smart Table Binding Model SAP UI5

I was trying to get the model data of Smart Table(Combination of Smart Filter and Smart Table). But I am not able to trace it. My Smart Table data is coming from OData entityset. I want to get the table data. Please suggest.
Regards
Karthik S
EDIT
Bounded data can be grabbed in dataReceived event:
Controller.js:
onDataReceived: function(oControlEvent) {
var itemCount = oControlEvent.getParameters().getParameter('data')['results'].length;
}
View.xml:
<smartTable:SmartTable
dataReceived="onDataReceived" ... >
Also this will be called each time the Go button has been pressed in the filterBar.
Underlying table can be accessed with smartTable's getTable() method. Depend on the type of the underlying table, for
sap.m.Table getItems()
sap.ui.table.Table getRows()
can be used to get the content of the aggregation.

Show Another Model Data in Admin Grid Magento

I am working on a extension in which Customer subscribe for Promotion, when Customer subscribe I will save user id, product id.
In subscriber module, I have to show Customer Name and Product Name.
So My Question is how can we Show Another Model Data in Grid?
If your extension uses a grid that extends Mage_Adminhtml_Block_Widget_Grid, you can modify the _prepareCollection() function to include data from other source (via joins). Also you will have to add new columns to the grid, which can be done in function __prepareColumns().
For an example look at the grid block of the Mage_Newsletter module Mage_Adminhtml_Block_Newsletter_Subscriber_Grid

Adding & Removing Associations - Entity Framework

I'm trying to get to grips with EF this week and I'm going ok so far but I've just hit my first major snag. I have a table of items and a table of categories. Each item can be 'tagged' with many categories so I created a link table. Two columns, one the primary ID of the item, the other the primary ID of the category. I added some data manually to the DB and I can query it all fine through EF in my code.
Now I want to 'tag' a new item with one of the existing categories. I have the category ID to add and the ID of the Item. I load both as entities using linq and then try the following.
int categoryToAddId = Convert.ToInt32(ddlCategoriesRemaining.SelectedValue);
var categoryToAdd = db.CollectionCategorySet.First(x => x.ID == categoryToAddId);
currentCollectionItem.Categories.Add(categoryToAdd);
db.SaveChanges();
But I get "Unable to update the EntitySet 'collectionItemCategories' because it has a DefiningQuery and no element exists in the element to support the current operation."
Have I missed something? Is this not the right way to do it? I try the same thing for removing and no luck there either.
I think I have managed to answer this one myself. After alot of digging around it turns out that the Entity Framework (as it comes in VS2008 SP1) doesn't actually support many to many relationships very well. The framework does create a list of objects from another object through the relationship which is very nice but when it comes to adding and removing the relationships this can't be done very easily. You need to write your own stored procedures to do this and then register them with Entity Framework using the Function Import route.
There is also a further problem with this route in that function imports that don't return anything such as adding a many to many relationship don't get added to the object context. So when your writing code you can't just use them as you would expect.
For now I'm going to simply stick to executing these procedures in the old fashioned way using executenonquery(). Apparently better support for this is supposed to arrive in VS2010.
If anyone feels I have got my facts wrong please feel free to put me right.
After you have created your Item object, you need to set the Item object to the Category object on the Item's Categories property. If you are adding a new Item object, do something like this:
Using (YourContext ctx = new YourContext())
{
//Create new Item object
Item oItem = new Item();
//Generate new Guid for Item object (sample)
oItem.ID = new Guid();
//Assign a new Title for Item object (sample)
oItem.Title = "Some Title";
//Get the CategoryID to apply to the new Item from a DropDownList
int categoryToAddId = Convert.ToInt32(ddlCategoriesRemaining.SelectedValue);
//Instantiate a Category object where Category equals categoryToAddId
var oCategory = db.CategorySet.First(x => x.ID == categoryToAddId);
//Set Item object's Categories property to the Category object
oItem.Categories = oCategory;
//Add new Item object to db context for saving
ctx.AddtoItemSet(oItem);
//Save to Database
ctx.SaveChanges();
}
Have you put foreign keys on both columns in your link table to the item and the category or defined the relationship as many to many in the Mapping Details?