Prevent vee-validate set dirty with data from API response - vuejs2

My problem is that I need to prevent users from leave a page when the form is dirty and ask then if they want to save changes before leave. But, using vee-validate, the form is dirty when its filled with data from API response and I need to set the form dirty just when user change a value on form. I tried sets programmatically but the dirty remains true.
I also tried to use touched, but it seems not work with vue-multiselect
Maybe dirty its not exactly what I need, but the same problem happens using changed for example
This is how I tried to programmatically change the dirty state:
Object.keys(this.$refs.form.fields).forEach(
(key) => (this.$refs.form.fields[key].dirty = false)
)
I also tried change only the form flag
this.$refs.form.flags.dirty = false
but without success

You can use resetForm
This will automatically set the dirty flag to false.
If you want to manipulate the form after you have set the values, you must use resetField

Related

Is there a way to stop myDataSet.HasChanges() returning true if the only change is a new row?

I have a Button on my Form that when clicked calls myBindingSource.AddNew(). Controls relevant to setting the values on that new row then become visible.
On the close event of that Form i call myDataSet.HasChanges() and if it returns True, i prompt the User if they would like to save the changes they have made.
In the situation where the User clicks to add a new row but then closes the Form, (for whatever reason) without setting any values, myDataSet.HasChanges() will return True obviously because there is the adding of a new row.
What i would like is a way to make it return False if the only change is a new row.
I have tried calling myBindingSource.EndEdit() then myDataSet.AcceptChanges immediately after myBindingSource.AddNew() but myDataSet.HasChanges() still returns True.
I thought by calling myDataSet.AcceptChanges() it would essentially wipe the slate clean and only changes made after that point would be picked up.
Or alternatively if there is a better approach to this i would like to hear it.
I am keen on the idea of only saving back to the DataBase in one go when prompting to save, rather than inserting the new row on the Button.Click and updating that row on each value change.
To be more specified than my comment:
If myDataSet.HasChanges(DataRowState.Deleted Or DataRowState.Modified) Then

VB.Net ComboBox (as Dropdown) not translating text to DisplayMember with Databinding

I inherited a fairly large project at work that is undocumented and written in VB (originally started pre .NET, ended around .NET 2). I'm in the process of updating / refreshing a lot of the code, but have run into an annoying issue that I haven't found the solution for yet. This system utilizes a UI, a Web Service, and a SQL DB.
Problem: I have a Databound Combobox (originally set to DropDownList - I'm changing it to DropDown, which is what started this mess - going back isn't an option) that is tied to a DataSet that comes from a Web Service. When a user types in the item they want manually, the data from the text field doesn't seem to associate itself with the DisplayMember, which forces the WS/SQL query to fail (it is sent a blank value when it's expecting a ValueMember). If the user types in a partial selection and then chooses the value they want from the DisplayMember list using the arrow keys or tab, the query goes off without a problem.
My Question: How do I get the text field to translate to the DisplayMember which will then properly tie itself to the ValueMember which will then allow the query to execute correctly? Sorry for making this sound complicated or convoluted; I'm sure the answer is easy and I'm just glazing over it.
The relevant bit of code is:
With cmbDID
If dtsLU.Tables.Contains(reqTable) = True Then
.DataSource = dtsLU.Tables(reqTable)
.DisplayMember = "zip"
.ValueMember = "gridID"
End If
End With
cmbDID.DataBindings.Clear()
cmbDID.DataBindings.Add("SelectedValue", dtsData, strDT & ".gridID")
I've tried changing "SelectedValue" to "Text", which almost works - but it directly translates to gridID and skips zip which ends up with an incorrect Web Service response since the zip and gridID field values are not synced (zip (DisplayMember) may be 5123 while gridID (ValueMember) may be 6047). I've tried changing "SelectedValue" to "SelectedIndex", and that got me no where.
Any help is greatly appreciated.
EDIT
To add some clarification to the process, the below pseudo code / description is roughly what happens. I could post the whole module, but I feel that would just muddy the whole question even more.
Private Sub A
FormAlpha is created with 1 ComboBox in the form of a DropDown
This DropDown is populated with a DataSet
DataBinding with a blank DataSet is added to the control to keep track of the users input
End Sub
lblSubmit_Click event is triggered on FormAlpha by the user after they have populated the DropDown with their data. lblSubmit_Click calls Private Sub Submit
Private Sub Submit
BindingContext(DropDown DataSet, tableName).EndCurrentEdit() is called
DataSet.HasChanges() is processed
If changes are present, changes are processed
HERE lies the problem
If the user has manually typed in the DropDown field, but not hit an arrow key or tab, then the DataSet registers a change, but returns a null value in all fields - it knows something was entered, but that data apparently didn't pass through the DataSet for the ComboBox (ListItems or SelectedIndex didn't change / fire I'm guessing). If the user selects the item with the arrow keys, the DataSet has the proper input (I'm assuming the Data was validated by the control at this point).
If the processed data is good, a value is entered into the database
If the processed data is bad (empty), an error is returned
End Sub
If the above can't be solved with what I've provided, but someone still knows a better way to handle this type of situation, I'm all ears. Rewriting the module isn't ideal, but fixing this problem is a necessity.
Alright, while this fix may not be ideal, it is a fix none the less.
The bare bones problem was that the text value of the DropDown wasn't causing the data to actually affect the SelectedIndex / SelectedValue of the control unless you interacted with it using the arrow keys or a mouse click. So, while the DropDown would read "1234", in reality the control saw "".
The fix I have in place for this is simply calling comboBox.text = comboBox.text whenever the user hits the submit button.

VB .Net Disable user row resize on datagridview

I am filling Datagridview with dataset and Datagridview has all resize properties set to false but, user can even resize rows. How could I disable it?
MyDatagridView.AllowUserToAddRows = False
MyDatagridView.AllowUserToResizeRows = False
MyDatagridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
...
I realize that this is an old post, but I had exactly the same problem. The AllowUserToResizeRows property may be overridden by the MyDatagridView.RowTemplate.Resizable setting. Try setting both to False, solved the problem for me.
In my experience,
MyDatagridView.AllowUserToResizeRows = False
does always prevents user to resize a row. I don't remember a case when it would be overriden by another property setting (and I use DataGridViews a lot). So I would say the line is not processed (you can debug it) or it is overriden by another setting later (track property value and see when it gets changed).
And by thew way, you can set it in the Datagridview Properties in VisualStudio, to make it a default setting.

xpages required property for a combobox

There is a djContainer having multiple djtabPane(s).
A combobox is situated on the first djtabPane, having the property: required="true".
but, when I move to next djtabPane in order to complete some other fields, I get the notification that the combobox value is required.
Can I achieve this property of the combobox but only if I want to submit / save the doc.?
<xe:djTabContainer id="djContentPane1" tabPosition="top" doLayout="false">
and the djTabPane ( all are the same, only the title is different ) :
<xe:djTabPane id="djTabPane1" title="Title1">
You'll need to move the validation to your save/submit method. A validator runs whenever a partial refresh happens unless you set immediate="true" or processValidators="false". But I don't think there's a way to set that on any of the in-built tabbed containers.
The advantage of Greg's approach when moving towards an MVC pattern is that the same validation can be run whenever saving the data object, not just from a specific XPage / Custom Control. The down-side is more work coding what's effectively in-built, e.g. tying the validation message back to the relevant component, setting the component's valid property to false etc.

Losing ability to change properties when changing SourceObject of subform in Access 2007

I have a subform that changes where it gets its data from based on user input by using the Me.SubForm.SourceObject = Query.SomeQuery. It seems that by doing this, I am losing the ability to set the BeforeUpdate property.
The code I am using is as follows:
Forms![PartsDatabase]![RepsSubform].Form![Pack Rank].BeforeUpdate = "=ToTracking()"
I have confirmed that this works before the SubForm.SourceObject is changed, but afterwards it throws the following error: RTE 2455 "You entered an expression that has an invalid reference to the property BeforeUpdate."
I was wondering if this is a known issue or if I just need to modify my code to adjust.
You are getting things muddled up here. You should never be changing Source Objects, rather you should be changing the Record Source. The code involved in the Form is Form level. If you wish to use the Before Update event, it belongs to the Form and not the Recordsource. So you always go to change the RecordSource.
You would use,
Forms!Parentform!SubForm.Form.RecordSource = "SELECT someFields FROM someTable;"
Or,
Forms!ParentForm!SubForm.Form.RecordSource = "yourCompiledQueryName"