Hi,
I am attempting to default a column value when adding a new item to an inline list control, however the field is not being populated. It appears that the edit event isn't being fired when I add a new item to the control. My exact code is below:
fd.spRendered(function() {
//prepopulating fields of a new record
console.log(fd.control('SPDataTable1')); //This object is logged
fd.control('SPDataTable1').$on('edit', function(editData) {
console.log(editData); //This object is not logged
//prepopulating Title
editData.field('Title').value = "Test";
});
});
Is there something I'm doing wrong?
Thanks
Hello @Andrew,
The code is correct and working properly on my side.
Which SharePoint version are you using? Online or On-Premises?
Are you getting any error in the browser console (F12)? Could you please share the screenshot of it.
Hi @mnikitina,
Sorry for the delay in reply, I am using on-premises.
I'm getting nothing logged in the console when I perform the inline edit action in the list control (it's successfully updating the item and I can see the traffic in the network section).
I've also tried binding to the change event in the same way, but also not firing:
fd.control('SPDataTable1').$on('change', function(editData) {
console.log(editData); //Not logged
});
The ready function does work and does log the object in the console:
fd.control('SPDataTable1').ready().then(function(dt) {
console.log(dt); //object logged
});
Hello @Andrew,
change event is raised when a user applies changes to the item in List or Library control. For instance, when a new file is uploaded or the item is edited.
edit event is raised when a user starts adding or editing a row in the inline editing mode. In the moment when a user edits line.
Please try out this code for List or Library control in inline editing mode. It logs the the type of the record:
fd.spRendered(function() {
fd.control('SPDataTable1').ready().then(function(dt) {
dt.$on('edit', function(editData) {
console.log(editData.formType);
});
});
});
Please make sure that you are using the internal name of the control. If you see any error in the browser console(F12), please share the screenshot.
Hi @mnikitina
Yes I was attempting to trigger both the change and edit events by making updates to the data in the list control.
I've implemented your code as above but even then nothing is logged in the console for the edit event, it's as though it doesn't exist. I've checked my version of forms is the latest for on-premises 1.4.8.
I have managed to capture a change event in the 'classic' jQuery method: within the fd.spRendered function:
$('div[internal-name="SPDataTable1"]').on('change', function(e) {
console.log(e); //object logged
});
However this doesn't give me access the function parameters of the Plumsail forms change event. I'm not sure what else I can do to troubleshoot this...
Hello @Andrew,
I've clarified this with my colleagues. List or Library 'edit' event for inline editing mode is currently available only in SharePoint Online.
It is planned to add this feature to the On-Premises version, but there is no estimation date yet.
Are you considering a paid support? We can implement new features to On-Premises version immediately. Please contact us via [email protected] to find more details.
Hi @mnikitina
Ok thanks for clarifying. Can I suggest to add a note on the methods that are available in which version on the documentation page for the control? As that would have definitely saved me hours of trying to get it to work: https://plumsail.com/docs/forms-sp/javascript/controls.html#list-or-library
I'll contact support as the objective is to update parent item fields in 'real time' when values in a child item change.
I have also been trying to do this using modal windows, however, the parent item in this case is open in a 2nd level modal window (as there are 3 levels of parent > child lists). Hence having the grid in the modal window would have helped in the transfer of data between parent and child, as it appears I can't reference a modal window from a child modal window. When referencing the parent window in this case the 3rd level modal form always references the top window and not the 2nd level modal.
Hello @Andrew,
Yes, I'm sorry for the confusion. We are planning to add version a feature became available in our documentation.
We will continue the conversation in the email.