TreeTableView: Cell Format dependent on another column (TornadoFx) - tornadofx

I have a treeTableView defined in TornadoFx
treeTableView = TreeTableView<EntityItem>().apply {
column("Id", EntityItem::id).prefWidth(200).cellFormat {
//how to refer to value of property Name ?
}
column("Name", EntityItem::name).prefWidth(200)
I want to format the cell 'Id' dependent on the value of the property/column 'Name'
How can I achieve this ?

You can access the item for the current row using the rowItem property. This might be null, so make sure you access it with the null safe operator (?).

Related

Missing Fields on Create stage of the Dynamics CRM Plugin

Is there a way to access empty fields of a Target entity in the preoperation stage when it has not been populated by the user?
The short answer is no.
Target only contains attributes whose values were changed or deleted.
Images only contain attributes that were chosen in Plugin Registration Tool. But they still do not contain attributes with NULL values.
If you tell us more about your development, maybe we could suggest something else.
You can access field by Entity.Contains() and Entity.GetAttributeValue<T>(). If field has not been populated, Entity.Contains() will return a false and Entity.GetAttributeValue<T>() will return a default(T).
Example:
// Entity.Contains(), use this to judge if entity contains a certains field.
if (targetEntity.Contains("yourfiledname"))
{
var field = targetEntity.GetAttributeValue<string>("yourfiledname");
if (string.IsNullOrEmpty(field))
{
// do your logic
}
}
// Entity.GetAttributeValue<T>() this return a T or default(T).
var optionsetField = targetEntity.GetAttributeValue<OptionSetValue>("someoptionsetfield");
if (optionsetField != null)
{
// do your logic
}

Storing Index value of a column in table and use it in other function/part of a code using cypress

I am trying to store the index value of column and trying to reuse it in other parts of code, but i am unable to do it. Can you please help me. I have attached the code as pic.i tired just by creating a variable and using alias. Both are not working.
If you want to retrieve the value from an alias you have to do this:
cy.wrap(ind).as('indexValueSourceDevice') //saves value with alias
//retrieve the value from alias
cy.get('#indexValueSourceDevice').then((indexValueSourceDevice) => {
//indexValueSourceDevice is available here
cy.log(indexValueSourceDevice) //logs it
})
You can get the header column index from invoke('index')
paginationElements.tableHeaderRows().contains('Source device')
.find('th').contains('Source device')
.invoke('index') // index of <th> in headerRow
.as('indexValueSourceDevice')
cy.get('#indexValueSourceDevice').then(indexValueSourceDevice => {
// for example, tbody cell for Source Device
cy.get('tbody tr td').eq(indexValueSourceDevice)
.should('eq', ...)
})
cy.get('#indexValueSourceDevice').then((indexValueSourceDevice) => { let indexReq = parseInt(indexValueSourceDevice.tostring()) If(index === indexReq){ //EXEXUTE CODE }}) This is working thanks to all for your help

WIX.com Primary key to be used as reference

I'm new to the WIX web development platform.
I need to use the Primary Key of Table 1 to be used as a reference of Table 2, but I cannot use the ID of table 1 for this purpose.
I wonder if the best way is to "copy" this ID in the Title field (Primary Key) of this table 1. How I do that? Is this the best method?
Thank you,
Arturo
Arturo:
Have you tried doing this without using wix code?
Check out this post to see if it is possible.
Now in code the only way to add a reference field from another data collection is to use the ID. But note that ID is the field name used in the data collection for dashboard and Editor view. When accessing the ID value in code you need to use the field key which is _id.
So in your Table2 you need a column (field) that is of type reference and give it a field name like "Table1 Reference". The editor will generate a field key for you that will look like table1Reference.
Now if you have a record from Table1 that you want to link to Table2 you do something like this:
wixData.query('Table1')
.eq('title', 'uniqueTitle')
.find()
.then((results) => {
if (results.totalCount !== 1) {
throw Error('We didn't get a record from Table1');
}
// Success add this in a new record in Table2
let table1Item = results.items[0];
let table2Data = {
table1Reference:table1Item._id,
anotherTable2Field:"Some info for table2"
};
return wixData.save('Table2', table2Data)
.then((savedRecord) => {
// Successful save!
// Do something here....
});
})
.catch((error) => {
console.log(error);
});
Good luck!
Steve

different structure of datasource for kendo grid leads to issues in filtering

I have a local datasource in the structure of the below:
Account:null
AccountId:null
Address:Object
---> Country:Object
--->Name:"Afghanistan"
CreatedBy:"System"
CreatedDateTime:"/Date(1457934873890)/"
Id:"ad92aa1e-5b48-41bf-a68a-52dfcab009e3"
IsDeleted:false
IsReferred:false
IsSystemData:true
Here I'm using some of the fields for kendo grid. Problem occurs when perform filter operation for country field. While binding the datasource to column
columns.Bound(c => c.Address.Country.Name).ClientTemplate(" #= Address.Country ? Address.Country.Name : '' # ").Width(110);
Country is a optional field in the form. If the user leaves that as empty, datasource will not be country name property. It will leave Address.Country as null. While filtering, for those empty country fields the error occurs as "Cannot read property of Name of null value".
Please guide me to overcome the situation. I tried by altering the datasource that is iterating the datasource and add a name property as empty to country object if it is null to achieve same structure for all the rows in datasource. Is there a way to avoid the iteration as our db has bulk datas.
Thanks
Someone correct me if im wrong.
The thing is that when you filter, the code tries to filter the binding not the template. thats why you have nullable values, you can edit the datasource before and do the condition before and then bind without having to do a client template.
you can also put some other "sort":
columns.Bound(c => c.Id).ClientTemplate(" #= Address.Country != null ? Address.Country.Name : '' # ")
This wont work? i cannot test because i dont have telerik right now installed.

How to pass values correctly from editor to grid?

I have table bound to set of elements with nested value. I made custom editor for this element which is kendoDropDownList. It loads dictionary values from server. It works fine, when i edit values, but when i create new element, dropdown inserts Id value (data-value-field="Id").
So i recieve that:
{
"Id":"",
"DateFrom":"2013-12-06 15:43:39Z",
"DateTo":"2013-12-06 15:43:39Z",
"Person":"3e31b740-7ced-4232-8cfc-cb3e100e372f"
}
but i need
{
"Id":"",
"DateFrom":"2010-10-09 23:00:00Z",
"DateTo":"2011-11-10 23:00:00Z",
"Person": {
"Id":"eeb97990-d191-4508-93c1-55f9ca3681d5"
}
}
I found solution! I defined defaultValue for my nested entity in schema of my table's datasource, it works for me.

Resources