Forum Discussion
Custom Connector and Navigation Tables
- 6 years ago
What you need to do is use Table.View, it is very powerful as it lets you reinterpate any code that transforms or drills into a table. In paticular you want to include a defination for the handler OnSelectRows:
View= (state) =>
Table.View(null,
[
GetType = () => ...,
GetRows = () => ...,
OnSelectRows = (selector) =>
let
condition = RowExpression.From(selector),...,
in
@View(newState)
])
The selector will be the abstract syntax tree of the query. If the code returns an error, then the view is handled by default logic and the next higher view in the stack will be tried.
Oh sorry, ignore everything with [Parameters] I was using that for letting users select functions.
What should I call instead? dataFunction([Name])??? what represents that function? artemus
- artemus6 years agoMicrosoft Employee
Yea, just remove the second parameter from the function.
You define the dataFunction, which returns the table result for the id value passed into the function.
- Anonymous6 years agoNot applicable
What should thatndatafunction return? and what the difference between datafunction([Name]) and datafunction(value) in OnSelectRows? artemus
- artemus6 years agoMicrosoft Employee
It should return a table based on its input.
If the user selects the "FooItem", then it will return the table for FooItem, by making the request and downloading that data.
The difference between the two is:
The first one is just a facade so that it shows up as a Table in the UI.
The second one actually gets called to get the data.
- Anonymous6 years agoNot applicable
OnSelectRows = (selector) =>
let
condition = RowExpression.From(selector),
kind = condition[Kind],
leftKind = condition[Left][Kind],
member = condition[Left][MemberName],
value = condition[Right][Value]
in
if (kind = "Binary" and leftKind = "FieldAccess" and member = "Name") then
Table.FromRecords({[
Name = value,
Data = dataFunction(value),
ItemKind = "Table"
ItemName = value,
IsLeaf = true
]})
elseartemus How to understand, which values are selected for rows filter? for example by which id to filter?
- artemus6 years agoMicrosoft Employee
OnSelectRows = (selector) => let condition = RowExpression.From(selector), kind = condition[Kind], leftKind = condition[Left][Kind], member = condition[Left][MemberName], value = condition[Right][Value] in if (kind = "Binary" and leftKind = "FieldAccess" and member = "Name") then Table.FromRecords({[ Name = value, Data = dataFunction(value), ItemKind = "Table" ItemName = value, IsLeaf = true ]})The code basicly says:
OnSelectRows = When this table is filtered, apply the following logic. This logic only handles: Table.SelectRows(table, each [Name] = "UserEnteredValue"), which is the extended form of table{[Name = "UserEnteredValue]}
condition = Get Abstract syntax tree for user's filter function
kind = Get the kind of the top level operation (this is expected to be "Binary", which includes all binary operations. The one we are interested in is equals ( = ))
leftKind : We expect this to be in the form of [Name], which is the same as _[Name].
member: This is what inside the []. In this case "Name"
value: This is the string the user is comparing with.
In general, Just run: = RowExpression.From(each [Name] = "MyValue") and see what it returns. Then make your code check and match the output of that, and get the "MyValue" string.