Filtering a Datatable Control [SOLVED]

Good day,

I noticed that it is possible to manually filter a datatable control in plumsail.
image

I'm trying to implement this functionality programmatically.
I've been through the documentation on datatables, but found nothing that mentions filtering.

It seems really silly that users can manually filter tables, but we cannot do it programmatically.
Please tell me I am wrong and point me in the right direction.

Regards
Dane

Source to documentation used:
https://plumsail.com/docs/forms-sp/designer/controls/datatable.html

For clarification on what I am trying to achieve.

When the user loads up the Display Form for a record, I would like to have to table pre filtered to only show records where column[2] (Mark) has the value "true".

Hello @drryan,

You can filter Data Table using the code:

fd.control('Control1').widget.dataSource.filter({
	field: 'Column1',
	operator: 'eq',
	value: 'test'
});
1 Like

Thank you Nikitana!
Absolute legend!

Can we please look at having the above added to the Data Table documentation?

Sharing the final code in case anyone wants an example:

/**********************************************
FORM HANDLERS
***********************************************/
function _formHandlers() {

    fd.control('DataTable1').widget.dataSource.filter({

        field: 'Column3',
        operator: 'eq',
        value: 'true'
    });
}

Another example in case the person needs to make sure the table is ready before applying the filter.

/**********************************************
FORM HANDLERS
***********************************************/
function _formHandlers() {

    fd.control('DataTable1').ready().then(function() {

            fd.control('DataTable1').widget.dataSource.filter({

                field: 'Column3',
                operator: 'eq',
                value: 'true'
            });
        }
    )
}