Getting the underlying data in tableau - tableau-api

The data representation was created in Tableau and I am accessing and showing it on my website through the Tableau JS API: link to the API.
Obtaining the viz and showing my Tableau have already been done. I have a Bar Chart showing my data in horizontal columns. The idea is that I want to be able to click on a column and then get the data which goes into this column.
Let's say we have 12 elements. They are represented by 3 columns. The first column has 5, the second 3 and the third 4 elements. In my case, after selecting the column with 4 elements I would want to be able to get the underlying 4 data entries.
I have been going through the API Documentation (link) and I have added on click listener for marksSelection. However, it only returns me the "sorting conditions" so to say. I tried getting the getUnderlyingDataAsync and then getData() but the returned data is not really in a format which I can use (since there are only pairs of row and column and not the full data entries).
Is something like this possible?

I solved it in a couple of steps following the API:
getUnderlyingDataAsync to obtain a DataTable, save it to an object called dataTable.
Get all of the (raw) data by calling dataTable.getData(). It returns a 2D array. To help you imagine the structure, let's say that the data source has 50 objects then the array will have a length of 50. If each object has 5 properties then the nested array will have a length of 5 (with each property represented as 1 element).
Get all of the columns by calling dataTable.getColumns(). Here you will need the name and index properties.
Create an object containing our actual JSON data by combining the columns in (3) and the (raw) data from (2).
Now you should have a structured array of objects.

Related

MUI DataGrid ColumnDef: the row is not available on the valueOptions prop of the column definition

I am using a DataGridPro component with different columns.
One one the columns is defined like this:
This issue is that I am trying to understand why the row is not available in the valueOptions prop of the column definition.
I would like to be able to populate the choices based on a list that is available on the row in another field.
But I get this error when I try to read the row:
Can you please help? The grid is populated with lots of rows coming from an api fetch.
Every other column is working fine accept this one.
Thank you.
I discovered that it was my bad. My column object was used twice with different parameters and so, yes, the row was not available for the second case.

PowerShell script to update SharePoint Online list items does not save all column values

I'm processing a CSV file to create SharePoint Online list items and save metadata as fields in its custom content type. At first, I thought it would be an issue related to column type, but I'm failing to save some simple text field values. What's puzzling is that I am able to save some but not other fields - even though I'm using the same means to do this - somehow the list item is not preserving all the values I send in for the list item update.
I create a new item with the following code:
$newFile = $targetfolderObj.Files.Add($FileCreationInfo)
$targetContext.Load($newFile)
$spContext.ExecuteQuery()
Then I get the list item and start setting the field values
$newFileListItem = $newFile.ListItemAllFields
$newFileListItem.Properties["ColumnNameA"] = $_.CustomValue1 # saves
$newFileListItem.Properties["ColumnNameB"] = $_.CustomValue2 # not saving !!!
$newFileListItem.Properties["ColumnNameC"] = $_.CustomValue3 # saves
After setting up the properties with values I call the update and execute functions.
$newFileListItem.Update()
$spContext.ExecuteQuery()
$.CustomValue1 $.CustomValue2 and $_.CustomValue3 when printed all read as "Hello" for example, there are no special characters or symbols here - even hardcoding the field values to simple strings will fail to update field 2 but works on 1 and 3.
I am giving this example with my code to show it's not sequential - for example field 2 data is NOT saved but field 1 and 3 data is saved.
It always fails on the same columns, I verified the columns exist, I'm using the internal field names, string length is well within range, and there is no other validation applied on these columns. What could I possibly do to troubleshoot this?
After a lot of debugging, I'm seeing SharePoint funnery at play...
while the content type is there, and the content type internal field name is "ColumnNameA" something must have gone sideways in the library instance, causing the column name to now be "ColumnNameA0" yes, a zero added at the end of the column name. Every column that was not updating had somehow now a "zero" at the end of the internal column name.
Solution 1: add the zero
Solution 2: recreate the library and re-associate it with the site conten type
I went with Solution 1 to test that my updates worked, then rebuilt the library.

How to update rows / set row data in server side row model type in ag grid?

My data model looks like this. Array of objects containing title and created_date.
{
title : String
created_date: Date
}
I have defined a column definition which only renders the title. However, I'd like to sort the rows based on the created_date, without creating a created_date column. There will be an external button detached from the table, which will call the api to get the data. I am using row model type serverSide. I have the sorted data from the backend. I just need to update the data / refresh the data. How can I achieve this ? I have so far tried setRowData(updatedRows). but its giving me an error saying cannot call setRowData unless using normal row model. Is there any way to update my rows in this serverSide row model type settings ?
Calling this.gridApi.setServerSideDatasource(myDataSource); and passing in your dataSource will do the trick. Check here for details

How to access a cell value when the column has been defined with ag-grid expression/value getters?

If the ag-grid column definition has been defined with a value getter or if an expression has been defined for a cell the value gets displayed fine on the grid. However I was not able to find a way to access a value in a given cell if the cell is using cell expression/value getters. Was trying to access the data through api.forEachLeafNode, but it seems even the in memory model does not have this data. The only way I found was to export the data as CSV and then parse it using getDataAsCsv(params).
Is exporting the data the only way to access value of a column in a grid with a value getter?
Why does the In Memory model not have this data to access?
valueGetter is used during the rendering stage, it only computes when needed to render the cell. if the cell is never rendered (eg row is below what is currently visible) then the valueGetter is never executed. the result is never stored in the model, it is only passed to the cellRenderer.
so what you need to do to get the result of valueGetter is use api.getValue(colKey,rowNode)
colKey is the id of your column. this can be the column itself (if you got the column from the grid column api) or the column id. the column id is what you will probably want to use. the column id is assigned to the column in the following order 1) the colDef.colId if exists 2) the colDef.field if exists 3) generated if both colId and field are missing. so if you are using a valueGetter, you are probably not providing a field, so just provide a colId.
rowNode is the row in question. this is what you get when you use api.forEachLeafNode.
the api.getValue() method is pretty recent, i know it's in version 7 - so if missing just make sure you are v7 or above.

How to get list of rows of selected sheet in Smartsheet using REST?

I'm trying to get list of rows of selected sheet. I went for REST API for rows List of row's related calls but didn't get any resource to get list of rows.
How can I get list of rows? or the REST call have not been written yet.
You can get a list of rows by using the Get Sheet operation. The response will contain the list of rows in the sheet, the list of columns in the sheet (which you'll need to interpret the cells data within the rows collection), along with sheet-level properties and any other data you've requested by using the include parameter.