I have an EditorTemplate with a ComboBox which is bound (via matching Name) to a property in my Model. The ComboBox is populated with some custom data objects via
.Name("MyType"
.DataTextField("Name")
.DataValueField("DBValue")
.DataSource( source =>
{
source.Read( read => { read.Action( "GetTypes", "MyController" ); } );
} )
I put a breakpoint at the click of the Submit button, and checked $('#MyType').val( ). It had a legitimate value ('ABC'). The value in the Model at this time was null. I put another breakpoint in the Controller at the Update action. At this point, the value in the Model was the string, '[object Object]'. This only seems to happen when the original value in the Model is null, but it is consistent when that is the case. Whenever the value in the Model is not null, even if it is '[object Object]', the next time I update it with the ComboBox, it stores the correct value.
What can I do to make sure the value from the ComboBox gets passed to the Update?
Apparently, as of this date, Kendo has a problem with ComboBoxes whose data-bound property is null, and their suggested work-around is to make sure the data-bound property is, in fact, not null. They are aware of this and are looking to provide for it in a later release.
Related
I want to make the custom filter dynamic. So, for writing future code I could pass in a list of references to each field object in the table.
That way I do not have to hardcode data.(field name here). Instead, it would work off the list of properties of the column object.
I know there ways to get the field normally but they are always returned as strings not object references. This obviously will not work with the dot operator.
I have some success with using JSON.parse followed by looping through the entries. But like before it returns the field as a string instead of a reference.
So is there a way to retrieve the column fields as objects and if so how?
I tried using the getColumns but I am still getting undefined when grabbing the fields. There is something wrong with my code.
function customFilter(data, filterParams) {
//data - the data for the row being filtered
//filterParams - params object passed to the filter
for (column of table.getColumns()){
field = column.getField();
console.log(data.field);
}
}
You speak about references in your question, but references to what? the field names themselves arent references to anything, they simply show Tabulator how to access the underlying row data, without a specific row data object to reference, there isn't anything to build any references from
You can only have a reference if it points to something, but there is nothing for the field definitions to point to without the row data.
If you are looking to have objects that you can manipulate the the getColumns function returns an array of Column Components with each component having a range of functions that can be called to manipulate that column. including the getField function that returns the field for that column.
Given that the Tabulator filter functions will accept the filed names with dot notation that shouldnt be an issue at all, but you can also pass the column component directly into the filter, so it shouldnt be a problem their either
I have a sap.m.table which is binded to a JSON "TRIP" model.
Each row of the table got a change button, that opens up a dialog to change the value for columns for that particular row. On change button click i am saving the original values in "temp" JSON model.
There is a cancel button to close the change dialog,
On cancel button i am getting the original values from "temp" JSON model and setting the values by setProperty() in the "TRIP" JSOn model. As soon as any values are manually changed in the dialog both of the models "TRIP" JSON model and "temp" JSOn model are getting updated with the new values.
I am not able to get the original values from anywhere. I have also tried to do oneway binding on the temp json model but it didn't work.
Please suggest what should i do to store the original values.
Thanks
.
I have use $.extend to clone the temp model.
It has solved the problem.
I created a series of switches in my Gmail add-on.
After clicking a button, I want to access the values of the switches. Some of the switches can have the same field names, which I'm setting using
Switch::setFieldName function, like so:
var switchKeyValue = CardService.newKeyValue()
.setSwitch(CardService.newSwitch()
.setFieldName(email)
.setValue(name));
Later on, I am iterating over the input values (values of the switches) of the sent form using:
// "e" is the event object passed to the event listener
var form = e.formInput;
var emails = [];
for (key in form) {
if (form.hasOwnProperty(key)) {
emails.push(key);
}
}
Normally, you would expect that the fields with the same name would have their values overwritten as they would be added in the formInput object.
For example, if I added 3 switches with the field name "car" and values (in this order) "red", "blue", "green", the resulting form would include only {"car": "green"}.
However, the documentation for the setFieldName function says:
"Unlike other form fields, this field name does not need to be unique. The form input values for switches using the same field name are returned as an array. The array consists of the values for all enabled switches with that field name."
So one would expect to receive something like {"car": ["red", "blue", "green"]} instead.
Yet, I am only getting string values for each of the switch, never an array containing multiple strings.
As a workaround I set the field name to contain both the original field name and the value of the field using a concatenation of the strings (and a split character), so that I get a set of ALL the widget values. However, this is not ideal, since I have to later split the string to parse out the key and the value of the field. Besides, it might not even work if the split character is a part of the original field name.
Basically, I want to collect all the switch values of the form, but need to keep track of the ones that are related (those having the same field name).
What is the best way to achieve this?
I'm trying to creating a global service in angular app with BehaviorSubject.
I have created a method in this service where I have defined a HTTP get method and loading JSON file.
Now the issue I'm facing is when I'm subscribing this BehaviourSubject as asObservable in any component and assign the result to a particular variable in the typescript file, the HTML template renders this value correctly via structured Directive *ngFor but when I'm trying to get the same value in typescript file, it does not work.
For example;
When I'm trying to print this value
console.log(this.data.boxes.length);
then it gives me an error
[ERROR TypeError: Cannot read property 'length' of undefined]
and when I'm trying to print this value without length
console.log(this.data.boxes);
it gives me a proper value of an array in the console panel.
Now If I change BehaviorSubject to Subject, then its working fine means I am also getting length value.
However, I want to use BehaviorSubject instead of Subject.
What am I doing wrong and how can I achieve it?
Behavior subject is emitting current value to subscriber even if subject next is not called before subscription, in other words:
yours subscription is subscribed to subject before first "next" value. I assume that initial value of behavior subject is undefined or similar, so that first value that is emitted to subscriber is causing error.
Could you check declaration of subject and ensure that initial value is in correct form, like:
public exampleSubject = new BeahviourSubject<yourType[]>(<yourType[]>[]);
I have a datagridview that is populated with the data I retrieved from the database (mysql)
When I try to hide the column or change the column header text, this exception was thrown:
Object reference not set to an instance of an object.
or
Index was out of range. Must be non-negative and less than the size of
the collection. Parameter name: index
with this simple code:
gridjobs.Columns(0).Visible = False
gridjobs.Columns("JOB_NO").HeaderText = "JOB NO."
I can tell you that the datagrid is not null, it was working before but suddenly this error popped up. I tried searching the net but still no luck in fixing this error. Everything is working, except this. Is there something wrong with my code?
based on google
Object reference not set to an instance of an object. exactly what it says, you are trying to use a null object as if it was a properly referenced object. ... Most of the time, when you try to assing value into object, and if the value is null, then this kind of exception occur.
This one is common sense here is your code.
gridjobs.Columns(0).Visible = False
gridjobs.Columns("JOB_NO").HeaderText = "JOB NO."
the first column is Visible = False then you assigned a header text? How can I assign a value in an Object that Invisible?
Just a wild guess.
and also why do u need to assign a header that will be visible = false also? anyway try this
gridjobs.Columns(0).Visible = False
gridjobs.Columns(0).HeaderText = "JOB NO."