I have a set of data like the following example and i would like to load it into the grid. However, i'm not sure how since the data doesn't have an name.
[[48803,"DSK1","","02200220","OPEN"],[48769,"APPR","","77733337","ENTERED"]]
What you need is just use the following localReader
localReader: {
repeatitems: true,
cell: "",
id: 0
}
I made for you the demo which shows live how it works.
UPDATED: How I could find out the reality is not so good as the documentation. The usage of localReader could help you to fill the grid contain with data from data parameter with the custom structure, but another parts of jqGrid: local sorting and searching don't work correct with this structure of data parameter. I interpret it as a bug. As a pragmatical solution I would recommend you to convert your custom data to array of named objects like
[{id:48803,col2:"DSK1",col3:"",col4:"02200220",col5:"OPEN"},
{id:48769,col2:"APPR",col3:"",col4:"77733337",col5:"ENTERED"}]
with the names corresponds to the column names in the colModel. If you will use data parameter in the form, everything will work perfect in jqGrid.
UPDATED 2: Look at the source of the fixed example and it will be clear what I mean. In your case conversion of the data can be about the following
var myNewData = [];
for (var i=0,l=mydata.length; i<l; i++) {
var d = mydata[i];
myNewData.push({id:d[0],col2:d[1],col3:d[2],col4:d[3],col5:d[4]});
}
The solution is not so elegant like with localReader, but it work without any restrictions.
Well, I'm not very familiar with jqgrid, but you could simply assign your data to an associative array and then load it.
Example here:
http://jsfiddle.net/QWcrT/
Related
I am using angular js datatable for my project. Currently I am trying to access below object,
"finalizedArr":[
{
"treaceId":"KYC454353545",
"approval":[
{
"usr":"kalindu kumara",
"threshold":100
},
{
"usr":"kuma kalil",
"threshold":80
},
]}
]
I am using below code sample to generate table. This is the main part code
$scope.dtColumns = [
DTColumnBuilder.newColumn('traceId').withTitle('Trace ID'),
DTColumnBuilder.newColumn('approval.usr').withTitle('Name'),
DTColumnBuilder.newColumn('approval.threshold').withTitle('Match Strength %')
];
When I use this code, treaceId column is correctly rendered in the table. but 'usr' and 'threshold' not rendered. I think reason is ,usr and threshold inside the array. but i do not know how to modify this. Can you check my issue
Out-of-the-box ngTable dynamic expects column.field to be property names, not navigators. (i.e. it doesn't handle dot syntax oneProperty.anotherProperty as it effectively does columnObject["fieldNameYouProvided"])
You could try a similar solution as noted here or you could try mapping your data model to a flat object.
Lastly, approval.usr and approval.threshold are not valid property accessors for the provided data model because approval is an array so to access the first values you would access them with approval[0].usr and approval[0].threshold which will not work as a dynamic column field property value for the aformentioned reasons.
I am new to extjs framework and looking for a way to add a custom sorting function to a column in a panel. I went through some of the post, and it seems that this functionality has been changed a few times over time.
In 5.0.1 documentation I found sortType configuration that can be used to convert the data to a comparable value.
But in my case, converting all the data to a value and then sorting could be a time consuming process and I was looking to use a function like the one used in doSort configuration earlier similar to this example; by basically configuring a function like this:
function customSorter(state){
var ds = this.up('grid').getStore();
var field = this.getSortParam();
ds.sort({
property: field,
direction: state,
sorterFn: function(v1,v2){
//some custom logic
}
});
}
EDIT 1: I am looking to use this function for only one column, the other columns are standard data types and sorting works fine by default for those.
Any ideas how to do this in 5.0.1?
Thanks in advance..
You can pass an array of Ext.util.Sorter to the sort method of your store. The Ext.util.Sorter class has an sorterFn config.
references:
https://docs.sencha.com/extjs/5.0.1/api/Ext.util.Sorter.html
https://docs.sencha.com/extjs/5.0.1/api/Ext.data.Store.html#method-sort
If you want to have a custom sort for a specific colum you can use the sortType config on the field corresponding to the column, see https://docs.sencha.com/extjs/5.0.1/api/Ext.data.field.Field.html#cfg-sortType
I know this is a SharePoint question, but I feel more like it is a javascript question also. I'm using this great tool to fill some of the fields in my SharePoint list (web part). It works great when I do this one by one, but I'm trying to request multiple column values, but I can't get it to work.
var thisUsersValues = $().SPServices.SPGetCurrentUser({
fieldNames: ["ID", "Name", "SIP Address"],
debug: false
});
How can I get specific column value (e.g. "Name") from this array?
Thanks!
Looking at the source it appears that the SPServices.SPGetCurrentUser() function returns an associative array with the keys being the fieldNames that were passed to it.
This means to access the field you can use
thisUserValues.Name
Or
thisUserValues['Name']
Disclaimer: I have no experience with sharepoint or this particular jQuery library.
I have a grid which data is like this:
As you can see, there are some rows (0,1,2 and 3 objets) and inside each there are more objects. Please pay attention that there is an object called 'datosPersonales' ('personalData') with has inside more objets; nombre (name), apellido1(firstname) etc.
The problem arise when I try to get the data from one row:
var empleado = $("#GRID_empleado").jqGrid("getRowData",numRow);
What I get is and object with object inside but the the previously mentioned 'datosPersonales' objetc is not a 'father' of more objects. With an image (from firebug) is easier to understand:
I don't know why but instead of get 'datosPersonales' with his 'sons' I get them like these:
datosPersonales.nombre
datosPersonales.apellido1
datosPersonales.calle
etc
What is the way to get all / whole / raw data from a certain row of a grid or even of the complete grid?
I have tried with some parameters but I've not been successful.
What I want is to get for example the data of [3] in the first image.
Thanks in advance!
You don't posted any code which shows how you use jqGrid. Even such important options of jqGrid like datatype and loadonce are unknown. So I can only guess. I suppose that you create grid with subgrids to display all the data which you posted. I suppose that you use approach close to the way which I described here and here. In the way you can use either getLocalRow or .jqGrid("getGridParam", "userData") instead of getRowData. If you don't know the answers which I referenced I recommend you to read there.
I tried to find the answer a lot but no way. I have an Ext.data.ArrayStore store and want to get its data as string. I tried store.getRange(), store.getAt() but I couldn't figure out what these functions return. Is there any way to get ArrayStore data as string?
I am newbie to extjs, so if you have any example on this, I'd appreciate.
It really depends what you want to do with the data. For most UI widgets and that sort of thing, you'll want to just use the store directly. If you want to get a piece of data from the store for tweaking manually, that's a whole nother story.
store.getRange() will indeed return all of the records from the store, but they are returned as an Array of Record objects. Records contain an attribute called data which is an object containing any properties you defined in the record's config.
Example:
Ext.each(store.getRange(), function (item, idx, a) {
for (var i in item.data) {
console.log(item.data[i])
}
})
That should show you every item in every Record in store
EDIT: Changed my answer to not be totally wrong.