Tabulator : Field ID when importing from a javascript dataArray - javascript

I'm using Google script to create a webapp.
I've got data from my google GSheet and loaded it into an array, called 'data' using javascript.
Using Tabulator, I can display the data in a table by using the autoColumns feature.
However the Table header fields are listed as 0,1,2,3 even though the first record contains the actual fields names. (Email, Status, Last Login, etc)
When I try and create my own header names, it requires the filed name - field:"xxx"
So my question - how do i find that field name....
columns:[
{title:"Email", field:"**xxx**"},
]
I've used 0,1,2,3 - didn't work
Col1, Col2, Col3, Col4 - didn't work
Not sure what else to try?
Thanks in advance.

You need to look at the array of objects you are passing into the Tabulator data property
The field value for each column is the property name in the row data object
For example if your row data object is:
{name:"steve", age:23, driver:False},
Then the column definition for the name column would be:
{title:"Name", field:"name"},

Related

Qualtrics: How to record which version of dynamic text was displayed to participant?

I am dynamically creating a table describing two hypothetical programs that I want participants to choose from:
To accomplish this, I have used java code that pulls from a list of opritons (for example, gender: men, women, trans-men, trans-women):
I use html to display the randomly selected word in the table:
And it successfully fills the table with text to participants.
I have added the variables to my survey flow:
**However, when I look in the dataset, the columns are empty (i.e., it does not record the version of the randomized word that was displayed to participants!
Any help would be much appreciated**
The random* column in the dataset is empty, because you are not storing anything over there.
The setEmbeddedData uses the following format ("Embedded Data Name", "Embedded Data Value"). So instead of creating my_word1 in your survey flow, create the embedded variable word1, because that is what you are storing.
The values already exists in your database, so you should be able to see these for previous responses also.

How to Filter for Non-Standard Columns in Sharepoint REST Api

Is it possible to determine which columns in a SP List or document library were custom generated by the user? I'm essentially trying to recreate SharePoint's front end in my app, and I want to add columns to my table just like if the user adds a column in SP. My issue is determining which columns are non-standard.
I already know how to get properties for list items/files and I can see my user generated columns in the response. I'm just looking for is there a way to filter for only non-standard columns?
User Generated Column in SP
Column in Results (as well as all other default fields)
We can use the REST API below to get the custom fields from a custom list.
http://sp2013/_api/web/lists/getbytitle('CustomList')/fields?$select=Title&$filter=FromBaseType eq false
For document library use this.
http://sp2013/sites/team/_api/web/lists/getbytitle('Documents')/fields?$select=Title&$filter=FromBaseType eq false and Hidden eq false and CanBeDeleted eq true and substringof('SourceID="{',SchemaXml)
I find the most reliable way to determine whether field is built-in or it a custom one is to utilize SPField.SourceId Property:
Gets either the namespace that defines a built-in field or, if it a
custom field, the GUID that identifies the list or Web site where it
was created.
In case of SharePoint REST API, SourceId property is not exposed but could be extracted from SchemaXml property
The following example demonstrates how to retrieve all the custom fields from a list:
https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')/fields?$select=InternalName&$filter=substringof('http://schemas.microsoft.com/sharepoint/v3',SchemaXml) eq false
Once the list of field is retrieved, the values of list items could be retrieved by specifying field names in $select expression:
https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')/items?$select=<fieldname1>,<fieldname2>
Update
The encountered error
Cannot find resource for the request fields
tells that requested resource(library in this case) could not be found, make sure to provide library title for getbytitle method:
https://site.sharepoint.com/_api/web/lists/getbytitle('<list title>')
^^^^^^^^^^^^^^

Sql query for data stored as JSON

I have data stored in column as JSON, as shown below:
{"category":{"value":CAT, "demo":A.......
I want to query in SSMS and want an output like:
CAT
I tried "SELECT JSON_QUERY(TABLENAME,'$.CATEGORY') FROM TABLENAME" which gave result of the
{"value":CAT, "demo":A....... but I want only CAT. How do I do that?
Use JSON_VALUE to get specific values.
SELECT JSON_VALUE(TABLENAME,'$.CATEGORY.VALUE') AS Value
JSON_QUERY is for JSON fragments.
Source
You should use JSON_VALUE.
SELECT JSON_VALUE(ColumnName, '$.category.value') FROM TableName
Take note of the first parameter, it should be the column name, not the table name (as opposed to your example).

jqGrid onCellSelect Return Property from Local Data

I've run into an issue using jqGrid 5.2.1.
I'd like to retrieve a property from a row of data when a user clicks on a cell. The property is in the original data set, but it isn't displayed in the grid. Also, I'm using the scroll feature, so the row ID's are coming back like "jqg20".
I've tried using getRowData, but that only returns the data that is displayed in that row. getLocalRow will not accept the row ID with "jqg" in it. Is there another way that I can access the same row in the local data that the user clicked in the grid to pull out a property? The property 'attr' is what I want to pull out in the example:
var testData = [
{col1:10, col2:20, col3:30, col4:'TEST', col5:50, col6:60, col7:70, col8:80, col9:90, col10:100, attr: {property: "this is column 1"}}
]
Here is the jsfiddle that I've created to show the problem:
https://jsfiddle.net/rhv247q7/
Before to answer of the direct problems I need to do some notes.
It is recommend to use the jqGrid version where the problem persist. You tell us for version 5.2.1, but you use 4.6, which we think can come to some uncomfortable situations.
It is always good idea to set id row – this can be done either in the description of the colModel (key : true) or with the appropriate reader in this case localReader. When you set this you will be sure that there will be not a problems getting certain row and some other important commands. It is not good idea to let the grid create the ids.
Now to the problem : to do what you want you should use the getLocalRow, which return the data as it comes to the grid – i.e the original data.
In your case there was a bug when scroll is on and no id is set from the developer (i.e. the grid creates internally the id). The problem is fixed in GitHub and you can test it.

insert data into specific column cell using datatables jquery

I've searched into the documentation of data tables of how one can add data to the table here
https://datatables.net/examples/data_sources/index.html but no where I could find a way to insert data into a single cell for a given column. For example, I need sth like:
"columns": [ {target (0), "value which will be inserted"} ]
There is a way to inser data from an array but each section of the array contains values for the whole row ( see here https://datatables.net/examples/data_sources/js_array.html) but I need to insert data into different cells in respect with the columns since I don't know the column labels initially. This is because the data will be in json format and first I need to extract the unique dates for each json object. These will be my column headers. And then for each of the objects based on its date I need to put it into the relevant date column. So the logic should be sth like:
if this date column (from the table) == json object date then put it there
Thanks
It seems like after a lot of researching this feature is not available in DataTables. So that's why I've solved the problem with jQuery. Using the code below I can iterate through a column and insert values in it.
//change 1 to the column at hand
$("#table tr > :nth-child(1)").each(function(index) {
//skip the column header
if (index > 0){
//insert value
$(this).html("<span class='fixed-size-square'> value to be inserted");
}
});

Categories

Resources