JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Data Grid › Update TreeGrid DataSource › Reply To: Update TreeGrid DataSource
Hi Walter,
For your particular case I would suggest you to take a look at the dataGrid update data demo where you will find a case similar to yours.
However I have made a code snippet with a code with the result you want to achieve:
var firstNames =
[
“Andrew”, “Nancy”, “Shelley”, “Regina”, “Yoshi”, “Antoni”, “Mayumi”, “Ian”, “Peter”, “Lars”, “Petra”, “Martin”, “Sven”, “Elio”, “Beate”, “Cheryl”, “Michael”, “Guylene”
];
var lastNames =
[
“Fuller”, “Davolio”, “Burke”, “Murphy”, “Nagase”, “Saavedra”, “Ohno”, “Devling”, “Wilson”, “Peterson”, “Winkler”, “Bein”, “Petersen”, “Rossi”, “Vileid”, “Saylor”, “Bjorn”, “Nodier”
];
var productNames =
[
“Black Tea”, “Green Tea”, “Caffe Espresso”, “Doubleshot Espresso”, “Caffe Latte”, “White Chocolate Mocha”, “Caramel Latte”, “Caffe Americano”, “Cappuccino”, “Espresso Truffle”, “Espresso con Panna”, “Peppermint Mocha Twist”
];
var priceValues =
[
“2.25”, “1.5”, “3.0”, “3.3”, “4.5”, “3.6”, “3.8”, “2.5”, “5.0”, “1.75”, “3.25”, “4.0”
];
// myDataSourceArray its just an example data
var myDataSourceArray = [firstNames, lastNames, productNames, priceValues]
updateBtn.onclick = () => {
console.log(‘DataUpdated’)
const grid = document.querySelector(“#treegrid”);
grid.dataSource = new window.Smart.DataAdapter({
dataSource: myDataSourceArray,
dataFields: [
‘id: number’,
‘firstName: string’,
‘lastName: string’,
‘productName: string’,
‘quantity: number’,
‘price: number’,
‘total: number’
]
})
}
Please, do not hesitate to contact us if you have any additional questions.
Best regards,
Yavor Dashev
Smart UI Team
https://www.htmlelements.com/