I created a datatable looking like the following: I want to store all the project numbers in the first column (Project) of the data table into the text field called Project_Num text field. How do I achieve this? And how I can delete the project numbers in the textfield when the project numbers in the datatable are deleted as well? Thanks.
You can use the code below to prepopulate column value for new row. Make sure you are using valid control and field internal names in the code.
fd.spRendered(function() {
//select the Data Table control to automatically prepopulate new rows
var dt = fd.control('DataTable1');
var isNew = false;
dt.widget.wrapper.find('.k-grid-add').on('click', e => {
isNew = true;
});
dt.widget.bind('edit', function(e) {
if (isNew) {
isNew = false;
e.model.set('Project', fd.field('Project_Num').value);
}
});
});
You can find more code examples for working with the DataTable in our documentation here.
I think you have misunderstood me. I meant to say that i don't enter anything in the "Project_Num" textfield. I only enter in the datatable. When I have multiple project numbers filled out in the datatable, I want to transfer these project numbers from datatable into the "Project_Num" textfield.
if I were to delete project numbers in the datatable, the changes should get reflected too in the "Project_Num" textfield.