here is a structure:
[{
key: value,
key: value,
key: [
key:value,
key:value
...
],
...
key:value
}]
I'm trying to bind it as a kendo DataSource and display as a kendoGrid elemnt. There is no problems with 1st level key:value pairs, but I broke my brains trying to get right with content of array. Is it even possible and, if yes, what am I doing wrong? If not - what is the best way to bind that?
It's hard to say what is going wrong without some more context on what you're trying to do but just judging by the fact that it's a dataSource, try changing:
key: [
key:value,
key:value
...
],
to:
key: [
{key:value},
{key:value},
...
],
Related
I have a csv file which I converted to an object:
[object Object] {
key: "2020-07-09",
values: [[object Object] {
cases: "49174",
date: "2020-07-09",
deaths: "1068",
fips: "01",
state: "Alabama"
}
}
I want an output of this object as a nest, something like this:
key: "2020-07-09",
perstate: {
"Alabama" : "49174"
}
I am not aware how to convert two values into a key value pair
Say the object is in an array, called data.
data.map(d => ({
key: d.key,
perstate: {
[d.values.state]: d.values.cases
}
}))
We use an ES6 arrow function for conciseness, putting the object literal in paranteses to indicate that the function returns an object.
To compute the key, we use ES6 computed property names. This allows us to get the value at values.state and use it as the key.
The app i made is a movie website that shows movies based on your search. You can also add favorites, however its not linked to your profile. So the solution i came up with was to make another value in the profile initial state in redux.
export const profileInitialState = [
{pass: '123', user: 'daniel', email: 'daniel#123.com', favourites: 'batman' },
]
interface IProfileState {
pass: string,
user: string,
email: string,
favourites?: string
}
and just map it from there
{data.profileReducer.slice(data.profileReducer.indexOf( {user: currUser, pass: password, email: email}, 1)).map(info =>
<p key={data.profileReducer.length + 1.5} > {info.favourites} </p>)}
and even thought it works perfectly in the console, it tell me profileReducer.indexOf is not a function when i implement it in my code.
First of all, Array.prototype.indexOf() can't be used to find the index of object elements in the array.
How to get index of object by its property in JavaScript?. This link describes how you can get the index of array elements.
The error can be caused by a few reasons
data.profileReduceris undefinded or null
data.profileReducer is not an array
To get the current datasource filter with Kendo UI for jQuery, you can call dataSource.filter()
I can't seem to find the equivalent for the Vue.js version. I've created an example here. The filter is currently set on the 'ProductName' column to show results that start with 'c' via:
filterConfiguration: { field: "ProductName", operator: "startswith", value: "c" },
You can see this in the console by clicking the Log Filter button which logs out the value of:
this.$refs.localDataSource.filter
If you change the filter by clicking on the column header and changing 'c' to 'ch' you'll notice if you log the filter again, it does not change.
There is also no filter() function on the data source. Is there a way to get the currently applied filter?
I figured it out. You have to assign the filter object like this:
filterConfiguration: {
logic: "or",
filters: [
{ field: "ProductName", operator: "startswith", value: "c" }
]
}
Or if you don't want to load the grid with any preset filters, you need at least this:
filterConfiguration: {
filters: []
}
This will not work:
filterConfiguration: {}
I'm trying to implement the Fine Uploader for the first time and have a question. I've got the uploader pushing files to my S3 bucket. The issue I have is the file is being renamed to some sort of string.
Here's an example: 4f65aefe-c55b-42b0-afd4-b749c755e7e8.zip
I'd like to keep the original file name if possible. Is that possible?
Here is the script on the page with my current set of params:
var uploader = new qq.s3.FineUploader({
element: document.getElementById("fineUploader"),
request: {
endpoint: "mybucket.amazonaws.com",
accessKey: "ABCDEFGHIJKLMNOP"
},
signature: {
endpoint: "/wp-content/themes/zone/vendor/fineuploader/php-s3-server/endpoint.php"
},
iframeSupport: {
localBlankPagePath: "/wp-content/themes/zone/success.html"
},
cors: {
expected: true
},
chunking: {
enabled: true
},
resume: {
enabled: true
},
});
Am I missing something? Thanks in advance.
Yes, this is expected. By default, Fine Uploader S3 will use a UUID to name your object when sending it to an S3 bucket. In almost all cases, this is the safest behavior. If you change this value, you run the risk of overwriting existing files with new ones in the event of a name collision. The object is annotated with the original file name attached to an "x-amz-meta-qqfilename" header.
If you must save the object in S3 using a different name, you can modify the objectProperties.key option appropriately. A value of "filename" will save the object using the original filename. You can also set the value to a function where you can determine the name on-demand, even using values from some other location, provided your key function returns a Promise. Read more about this option at http://docs.fineuploader.com/api/options-s3.html#objectProperties.key.
I am using two datasources in the list view. The first one is list view datasource and the second one is local datasource. I am adding multiple items to the local datasource. On save click i want to save all the values in the local datasource to the database.
In the button click i am using localdatasource.sync() method to call the create method.
But it is not entering in to the parameter map.
Simply In my database i am having 10 list view items. Initially i am loading 1 item and on next button click i am loading next item. Then when i am saving the question on next button click to the local datasource. On complete button click i want to save all the values.
Regards,
Sri
Did you try to create a dataSource which is configured for remote operations and you populate it initially through the data field of the dataSource configurator?
Something like this:
dataSource: {
transport: {
read: {
"url": "/Home/GetPersons"
},
update: {
"url": "/Home/UpdatePerson"
}
},
data: {
Data: [{
PersonID: 1,
Name: "John",
BirthDate: "\/Date(-47876400000)\/"},
{
PersonID: 2,
Name: "Sara",
BirthDate: "\/Date(148251600000)\/"}],
Total: 2
}
//... etc. other options
}