Is there any method I can get the full JSON data from jqGrid when datatype is local along with the column name?
In this format: [{"firstname": "Chris"},{"firstname": "Dave"}]
You can use the getRowData method to return an array containing all of the grid data. For example:
var fullData = jQuery("#myGrid").jqGrid('getRowData');
Here is the documentation for getRowData from the jqGrid wiki, which helps explain what is going on:
getRowData
Parameters: rowid or none
Returns: array
Description:
Returns an array with data of the requested id = rowid. The returned array is of type name:value, where the name is a name from colModel and the value from the associated column in that row. It returns an empty array if the rowid can not be found.
If the rowid is not set the method return all the data from the grid in array
Update
You might also be interested in the data parameter, which can be used to retrieve the data passed to the grid. From the jqGrid docs:
An array that stores the local data passed to the grid. You can directly point to this variable in case you want to load an array data. It can replace the addRowData method which is slow on relative big data
For example:
var data = $('#' + gridid).jqGrid('getGridParam', 'data');
Does that help?
Related
In Qmetry,Trying to save array of arraylist string and access same in another test case.
Array of array list :
ArrayList<ArrayList<String>> my_list
store(my_list, "array_list_1");
//Accessing saved list
Object list_details = getBundle().getObject(array_list_1);
System.out.println("++++ saved list details++++" + list_details);
I am able to print list_details content. Till this there is no issue. But when I try to get the first index within the arraylist, not able to use .get(0) method. Below is the code.
ArrayList<String> list_details1 = list_details.get(0);
When tried typecasting , got an error 'java.lang.String cannot be cast to java.util.ArrayList'
typecast:
ArrayList<ArrayList<String>>list_details1 = (ArrayList<ArrayList<String>>)list_details;
Need to know is it the right way to store and access arraylist ? Please suggest.
if you want store in file, you can use .csv or .xls to save ArrayList<ArrayList> my_list, if ArrayList<ArrayList> my_list you query from database, you can set as static variable, then you can use in different method
How I could append an element to an array like that:
Using this code I'm overriding the old data:
let toUpdate = [book.id]
self.refUsers.child(localUser.key!).child("booksPurchased").setValue(toUpdate, withCompletionBlock: { (error, _) in
You could use this method: firebase.firestore.FieldValue.arrayUnion()
Example with angularfire2:
this.afs.collection('collection').doc(id).update( {
array: firebase.firestore.FieldValue.arrayUnion( 'newItem' )
});
For more information: https://firebase.google.com/docs/reference/js/firebase.firestore.FieldValue#arrayunion
In this case, you will have to read the existing data, then write it back with the new value added. Arrays like this are not always the best way to store lists of data if you want to perform a lot of append operations. For that, you're better off pushing data into a location using childByAutoId.
Reading and writing lists
Append to a list of data
Use the childByAutoId method to append data to a list in multiuser applications. The childByAutoId method generates a unique key every time a new child is added to the specified Firebase reference. By using these auto-generated keys for each new element in the list, several clients can add children to the same location at the same time without write conflicts. The unique key generated by childByAutoId is based on a timestamp, so list items are automatically ordered chronologically.
You can use the reference to the new data returned by the childByAutoId method to get the value of the child's auto-generated key or set data for the child. Calling getKey on a childByAutoId reference returns the auto-generated key.
You can use these auto-generated keys to simplify flattening your data structure. For more information, see the data fan-out example.
-https://firebase.google.com/docs/database/ios/lists-of-data
You could set the values of the keys in the array to true, and then set the value directly in an update.
So if 'newId' is the new item to add, maybe something like:
const update = {
[`/users/${localUser.key}/booksPurchased/${newId}`]: true]
}
firebase.db.ref().update(update);
Firebase docs example of an update:
https://firebase.google.com/docs/database/web/read-and-write
I want to load data from many files. Each file is named with a date and I need to inject this date to each of the fetched Entries of my file.
I know I could do this with an foreach - loop before inserting the data into the collection, but I think there should be a better solution.
Content of one file
[{"price":"95,34","isin":"FR0000120073"},{"price":"113,475","isin":"CA13645T1003"}]
The Code I use to move the data into a collection.
$collection= collect(json_decode(File::get($file)));
I tried for example the "map" method, however I don't know how to pass an additional variable to the anonymous function.
The content of my collection should look like this:
[{"price":"95,34","isin":"FR0000120073","date":"2016-06-23"},{"price":"113,475","isin":"CA13645T1003","date":"2016-06-23"}]
Is there any simple solution using the collections or do I have to use a foreach-loop?
May be this will help
$collection = collect(json_decode(File::get($file)));
$collection = $collection->each(function ($item, $key) {
//First iteration of $item will be {"price":"95,34","isin":"FR0000120073"}
$item->date = "2016-06-23"; //Insert key, value pair to the collection
});
I am calling an API that returns an array of JSON objects and I can access return values of the API call
[{"param1":1,"param2":"blah1"},
{"param1":2,"param2":"blah2"},
{"param1":3,"param2":"blah3"}]
I know that i can access each Param1 through iteration or by static indexing like #client[0].param1 #client[1].param1 #client[2].param1 but the thing is , i don't want param2 and i want just param1 . is there any way , to access param1 without iteration or static indexing
so that i could get the below result in response
[{"param1":1},
{"param1":2},
{"param1":3}]
Update
The thing to notice is that i want to filter the result while making
the request (before getting the response when we know the attribute
name)
Try to use delete.
Deletes and returns a key-value pair from hsh whose key is equal to
key. If the key is not found, returns the default value. If the
optional code block is given and the key is not found, pass in the key
and return the result of block.
data = [{"param1":1,"param2":"blah1"},
{"param1":2,"param2":"blah2"},
{"param1":3,"param2":"blah3"}]
data.each {|x| x.delete("param2")}
For more information about delete.
I hope this help you.
I'm building a plugin and I'm using actionscript to save the selection of an object in an illustrator document and then reference it later.
var arrObj:Array=new Array();
arrObj.push(app.activeDocument.selection[0]);
If I select now the same object in the document and check if its in the array it returns a -1 for the index value.
var id:int=arrObj.indexOf(app.activeDocument.selection[0]);
trace (id); //-1
Why is the selection not considered the same object as in that of the array?
I figured out a work around for saving the selected objects in an array and when selecting the object again in the illustrator document it would point out the index of that object in the array. Selected objects datatypes are "PathItems" and have a variable called name. All you have to do is set this variable to a value of your choice as well as saving it in an another array.
var arrObj:Array=new Array();
var nameHold:Array=new Array();
arrObj.push(document.selection[0]); // save the selection in an array
var hold:PathItem=document.selection[0];
hold.name="index1"; // setting the name variable of the selected object to a value of choice
nameHold.push(hold.name); // adding the name value in an array
Now the selected object and its corresponding name value are stored in arrays at the same index...you can compare all "PathItems" to each other by using the name variable and if the names match then you can get the index by using the .indexOf("name") method in arrays.