GXT Grid with multiple sources - gxt

I am trying to create a grid using GXT that contains data from multiple JSON sources. I've been able to get the grid working with one source, but can't figure out how to add additional sources to the grid or the ListStore.
// ...
ScriptTagProxy<PagingLoadResult<ModelData>> proxy =
new ScriptTagProxy<PagingLoadResult<ModelData>>(url);
ModelType type = new ModelType();
type.setRoot("root");
type.addField("source");
type.addField("description");
JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader =
new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);
final PagingLoader<PagingLoadResult<ModelData>> loader =
new BasePagingLoader<PagingLoadResult<ModelData>>(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
add(grid);
// ...
Is there a way to add additional loaders to a GXT ListStore? Ideas? Thanks in advance.

It looks like one method of populating a grid with multiple remote sources is to use borrow from the article http://code.google.com/webtoolkit/articles/using_gwt_for_json_mashups.html and create a 'mashup' class that populates a ListStore with the results as each response is returned.

Related

How do I add map markers to a separate class file?

In android studio I've created a map with hundreds of markers on it. I want to separate these into individual classes and put them in a separate package, so that there isn't one massive list of markers in my main code. Is there a way of doing this? I'm using Kotlin.
so what I think you are trying to say is.
There is an Activity let's say MainActivity and it has maps in it and has let's say some 200 markers on it.
and all are individually initialized and assigned and you want to club them all together so that you'll be able to use them just by searching for one.
if that's the case, what I would suggest is.
make a separate Data Class that stores Marker and other data related to it.
data class MarkerInfo(
//marker ID
val id:Int,
//marker Data
val markerData:Marker,
//other Data
var otherData:String
)
now coming to storing and accessing data.
class MainActivity(){
//at the top level, inside Activity
// This will create an empty list of Marker Info
var markerData = mutableListOf<MarkerInfo>()
//Now take any function, let's say x
private fun x(){
//Mark a Marker on Map and assign it to a variable.
val markerA : Marker = map.addMarker( MarkerOptions.position(somePosition))
//we assign a function with id and other relevant data
val x= markerData.size
//store data in list
markerData.add(MarkerInfo(x, markerA, "This is a very useful marker"))
}
}
//now to access that marker.
//let's say there is a function named y.
private fun y(){
//say we want to access the first marker
//there are two ways to do so.
//first method: you know some data which is already in there let's say we know id
for(i in markerData){
if(i.id == 1){
Log.d("TAG", i.toString())
}
}
//second method: directly
Log.d("TAG",markerData[0].toString())
}

How can I declare and add parameters to an Acumatica PXDataFieldParam object?

I'm using the Acumatica PXDatabase.Update method to update records in an Acumatica instance. The code I have is as follows, updating two fields and using another two as restrictors:
PXDatabase.Update<xTACProjectTask>(new PXDataFieldAssign<xTACProjectTask.dueDate>(tmpRow.Cells[indexMap["Due Date"]].Value.ToString())
, new PXDataFieldAssign<xTACProjectTask.startDate>(tmpRow.Cells[indexMap["Start Date"]].Value.ToString())
, new PXDataFieldRestrict<xTACProjectTask.projectID>(tmpRow.Cells[indexMap["TAC Project ID"]].Value.ToString())
, new PXDataFieldRestrict<xTACProjectTask.taskCD>(tmpRow.Cells[indexMap["TAC Task ID"]].Value.ToString()));
The PXDatabase.Update command uses a PXDataFieldParam array that contains the PXDataFieldAssign and PXDataFieldRestrict parameters, and the example above creates new instances of those inside the PXDatabase.Update method - but I'd like to find a way to declare the PXDataFieldParam object first and then conditionally add the PXDataFieldAssign objects to it, and finally passing that PXDataFieldParam array to the method.
I'd like to declare it something like this, but I can't seem to find the proper way:
PXDataFieldParam[] pfp = **????**;
PXDataFieldParam pf;
pf = new PXDataFieldAssign<xTACProjectTask.dueDate>(tmpRow.Cells[indexMap["Due Date"]].Value.ToString());
pfp.Append(pf);
pf = new PXDataFieldAssign<xTACProjectTask.startDate>(tmpRow.Cells[indexMap["Start Date"]].Value.ToString());
pfp.Append(pf);
pf = new PXDataFieldRestrict<xTACProjectTask.projectID>(tmpRow.Cells[indexMap["TAC Project ID"]].Value.ToString());
pfp.Append(pf);
pf = new PXDataFieldRestrict<xTACProjectTask.taskCD>(tmpRow.Cells[indexMap["TAC Task ID"]].Value.ToString());
pfp.Append(pf);
PXDatabase.Update<xTACProjectTask>(pfp);
Is there any way to do this?
Instead of defining an array of PXDataFieldParam why don't you define a List and then use the method .ToArray() when calling the PXDatabase.Update method.
PXDataFieldParam pf = null;
List<PXDataFieldParam> dbParams = new List<PXDataFieldParam>();
pf = new PXDataFieldAssign<SOLine.orderDate>(Accessinfo.BusinessDate);
dbParams.Add(pf);
PXDatabase.Update<SOLine>(dbParams.ToArray());

RowPersisted on two different DAC's are in infinite loop

I currently have custom RowPersisted events on SOLine and POLine in Acumatica. Basically I need to make sure that custom Vendor cost field in SO and unit price field in PO update each other for all the linked PO's and SO's, when user saves them in Acumatica. So I have something like this in POLine_RowPersisted:
soRecExt.UsrVendorCost = line.CuryUnitCost;
SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
graph.CurrentDocument.Current = soOrd;
var result = graph.Transactions.Select();
graph.Transactions.Update(soRec);
graph.Actions.PressSave();
And something like this in SOLine_RowPersisted:
poRec.CuryUnitCost = lineExt.UsrVendorCost;
POOrderEntry graph = PXGraph.CreateInstance<POOrderEntry>();
graph.CurrentDocument.Current = poOrd;
var result = graph.Transactions.Select();
graph.Transactions.Update(poRec);
graph.Actions.PressSave();
So unfortunately when one is updated the whole thing enters infinite loop. I have tried something like this:
POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
graphExt.RowPersisted.RemoveHandler<SOOrderEntry_Extension>(graphExt.POLine_RowPersisted);
However, there is no RowPersisted on graph extension. My events are set to public. Can someone help please?
The events are registered and triggered by the Base graph so you have to remove them on base graph.
I believe what you're trying to accomplish is more along the lines of:
POOrderEntry_Extension graphExt = graph.GetExtension<POOrderEntry_Extension>();
graphExt.Base.RowPersisted.RemoveHandler<POOrderEntry>(graphExt.POLine_RowPersisted);
Where 'graph' is of type POOrderEntry then using 'graph' is equivalent to 'graphExt.Base'.

How to change the value of a certain core data across VCs/ How to know the index of a created CoreData?

I start from a TableView to create and store user information. This is how I create a core data entity called "Trials" in CreateTrialViewController. And I can successfully fetch it in the tableViewController after I come back to it.
let trial : Trials = NSEntityDescription.insertNewObjectForEntityForName("Trials", inManagedObjectContext: self.managedObjectContext!) as? Trials
{
trial.project = theProject.text
trial.record = theRecord.text
trial.notes = theNotes.text
trial.percentile = ""
managedObjectContext?.save(nil)
}
'
But after I create the Trial, I will get some calculated results from the accelerometer in the next measureViewController, and I want to save the result into 'trial.percentile'.
I have already converted the results into a string, so I can write it directly into the core data attribute. But how can I know the index of this core data that I just created? Should I try to use 'segue' to transmit?
In the tableView it fetches in a ascending sequence of date, so the index is clear. But here in the following VC how to know the index? I still couldn't figure this out by myself... The sequence of my VCs is: TableViewController -> CreateTrialViewController -> MeasureViewController -> TableViewController (start again)
Your table view controller can keep a reference to the newly created object. Insert the object (trial) in the original view controller and pass it on to the next controller in prepareForSegue. So the CreateTrialViewController starts out with a blank object to which the table view controller has a reference.
You configure the object, go to the measure controller, modify the object. When done, you pop these two controllers from the navigation stack and are back in your original table view controller.
Because your table view controller has the NSFetchedResultsControllerDelegate enabled, it will update itself to reflect the data of your new object. Remember, you still have a reference to this object, so you can just use indexPathForObject to retrieve its index path.

How to create a LWUIT List screen in j2me?

i want to create a lwuit list screeen ,the list items are coming to my method from Rss Feed in a loop continuosly,but i am able to append 1 title from rss feed and able to display on device,after that 2,3,4,etcc...items are changing ,but finally,i am able to display 1 title and last title only,here is my code:
//method called by the parsing thread
public void addNews(News newsItem,Vector news) {
String newsArray[]={newsItem.getTitle()};
myNewsList = new List(newsArray);
System.out.println(newsItem.getTitle());//Here i am able to display,second title after that,it is not appending adding to myNewsList
//myNewsList.addItem(newsItem.getTitle());
form1.addComponent(myNewsList);
form1.show();
}
Can you help?
You need to read up about using Lists and the model in LWUIT. When using addItem you should invoke it from the EDT using LWUIT's callSerially method.
Regardless, calling addItem one by one is VERY slow. You should use a model to represent your data, see the makeover demo.

Resources