Create Add, Modify and View menu

My site is

I am trying to create a Add, Modify and a View option for form data.
Could you please help me with the following questions:

Q1 - Is it not possible to have the same dataset for the Add and View option on the same page ? - I had to to create separate pages for Add and View to make them work.

Q2 - How can I create a Modify option where the user selects a date and all data for that date is fetched and displayed. The user then can edit any of these records and click on submit button?

PS: I am absolutely loving WIX code :slight_smile:


thank you for your love!

To answer your questions:

Q1 - You can start creating a new item using the same single database, but your users would have to click a button. You can bind such button to New action in a data set. This will create a new item and will allow you to edit it. Otherwise input items to the dataset are bound to the currently active item being displayed allowing users to edit the item. Alternatively you can also use two different datasets on the same page, where one could be used to add new elements and another to view.

Q2 - this will require a little bit of code.

What we need to do here, is to set a custom filter to a dataset based on what the user has selected.

Lets say I have a date input field #datePicker and a dataset #dataset.

I can add the following code to my page to filter only the items that are newer than the selected date:

import wixData from 'wix-data'

$w.onReady(function () {
    // Initially filter out only elements newer than the selected date
    $w('#dataset1').setFilter(wixData.filter().gt('datetime', $w('#datePicker1').value))

// This function should be bound to date pickers onChange event
export function datePicker1_onChange(event) {
        // If date picker value was changed, we set the filter with the new value
	$w('#dataset1').setFilter(wixData.filter().gt('datetime', $w('#datePicker1').value))
	// And refresh the dataset to get new items matching the filter

Now you can bind the form elements and submit button to the dataset and you will be able to modify the currently visible element. You can also add previous and next buttons to navigate the items available for the dataset or choose any other selection mechanism.

I hope this helps. Have fun Wix Coding!

1 Like