I'm working on a small project in which I will work with dgrid dojo, the dgrid must be customized according to the profile of the person if he's administrator or simple user.
The dgrid will be filled from a REST service, and I had the idea to not only fill the dgrid but also customize it with textbox, buttons and checkbox.
For example here is the code of a dgrid with 2 columns whose fields can not be changed:
window.Grid= new StandardGrid({
sort: "abbreviation",
store: stateStore(),
columns: {
abbreviation: 'Abbreviation',
name: 'Name'
}
}, "MyGrid");
the service must verify if the person is an administrator and if so send in JSON Format the settings to add more features to dgrid, by changing "columns" with :
[ editor({
label: "Abbreviation",
field: "abbreviation",
editor: "text",
editOn: "dblclick"
}),
editor({
label: "Name",
field: "name",
editor: "text",
editOn: "dblclick"
})]
I want to send this configuration code in json format.
I want to know if this is workable and if so, how?
Thank you
Since functions aren't a valid part of JSON, you'd need to do some amount of processing to go between JSON and dgrid column plugins. For example, in the case of editor, you could just test each object for presence of the editor property, and if found, apply the editor function around it when you actually create the column structure from your JSON.
I'm not sure regarding Dojo. But if you want to convert a JS Object to JSON then simply:
var jsonString = JSON.stringify(objectGoesHere);
Related
I am using Salesforce metadata api to create a contacts list view with one filter. The filter should contain First Name.
metadata = [{
fullName: 'Contact.listViewName1',
label: listViewName1,
filterScope: 'Everything',
filters: [{
filter: "First_Name",
operation: "contains",
value: 'AUTO_'
}]
}];
I tried using 'filter' instead of 'field' and I get the following:
element {http://soap.sforce.com/2006/04/metadata}filter invalid at this location in type ListViewFilter
For standard field use FirstName, no underscore. If you have made a custom field - it'll end with __c so probably First_Name__c.
List of standard fields:
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contact.htm
For view including your custom fields you'll need to go to Setup -> Object Manager -> Contact -> fields and relationships
I don't know what you're using (jsforce? Tooling API?), what's normally being deployed using Metadata API should look like this. You'll need to do the XML - JSON translation yourself
<listViews>
<fullName>listViewName1</fullName>
<columns>FULL_NAME</columns>
<columns>ACCOUNT.NAME</columns>
<columns>CONTACT.PHONE1</columns>
<columns>CONTACT.EMAIL</columns>
<columns>CONTACT.TITLE</columns>
<columns>CORE.USERS.ALIAS</columns>
<filterScope>Everything</filterScope>
<filters>
<field>CONTACT.FIRST_NAME</field>
<operation>contains</operation>
<value>AUTO_</value>
</filters>
<label>listViewName1</label>
</listViews>
Documentation: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listview.htm
I have a customer that has metadata in each row describing what type of data is in the column. Is it possible to set editor for a column differently for each row?
var tab = new Tabulator('#tabId', {
data: data,
layout: 'fitColumns',
columns: [
{
title: 'Name',
field: 'LocationName',
},
{
title: 'Field',
field: 'Field',
editor: (cell, onRendered, success, cancel, editorParams) => {
// is it possible to just return one of the built in editors here, if so how?
// I only need text, date, checkbox built-in types, but need to determine which
// one dynamically based on data in the row.
}
}
]
});
This is not possible to do with standard editors, these must be defined by column, but you could could create a Custom Editor that could return one of a number of editors, and chooses which one to return based on the row data.
You can get the source for the inbuilt editors from the src\js\modules\edit.js file in the repo
After doing some tuts of the Kendo UI framework, I'm having problems using one of their widgets. I've only a basic understanding of the framework and this is even my first question ever in StackOverflow so... please spare me from "advanced" answers if possible.
So, here's the thing:
I want to use the Scheduler widget to make a timeline month view with data from a JSON file. The data (in JSON format) I'm planning to use comes from a SQL Server database that is called on the client-side by an Ajax call that connects to a web service. Sample:
Params.type = 'GET';
Params.url = 'LoremIpsum-YeahDomainService.svc/JSON/GetPeople';
Params.dataType = 'json'
To know if the web service is working fine, I tried to retrieve information from the database into a Kendo DropDownList and everything went okay. I did this script:
var getPeople;
getPeople = data.GetPeopleResult.RootResults;
var listPeople = [];
getPeople.forEach(function(person){
var newelement = { 'Name': person.Name, 'value': i, 'color': '#808080' };
listPeople.push(newelement);
});
After doing that script, I used the following script:
$("#dropdownlist").kendoDropDownList({
dataTextField: "Name",
dataValueField: "value",
dataSource: new kendo.data.DataSource ( { listPeople } )
});
As planned, I got all the data I wanted to see in the browser.
Therefore, now I want to produce script for the Kendo Scheduler with a timeline month view like this one without the "Meeting Rooms" section and I want the names of the persons that are called from the database.
Just like with the DropDownList, it doesn't matter if I have 30 or 300 person names. The persons on the Scheduler can't be static because the database will be updated often. In a nutshell, the names of the persons that are shown in the Scheduler must be provided dynamically from the database.
I already used multiple scripts from the Kendo UI Scheduler documentation as all my scripts for the widgets are based on their examples but until now, nothing worked out.
Based on the example provided in the Kendo UI documentation for the timeline month view, I've some of their scripts adapted such as:
dataSource: {
batch: true
transport: {
read: {
url: "http://localhost:50379/LoremImpsum-YeahDomainService.svc/json/GetPeople",
dataType: "json"
group: {
resources: ["People"],
orientation: "vertical"
Also in relation to the Scheduler script, based on the example provided on the Telerik website I did a script that would get the persons names from the database. Here it is:
var result = [];
result[0] = { text: "+getPeople[0]+", value: "1", color: "green" }";
for(i=1; i<getPeople.length(); i++){
resultado[i] = ", { text: "+getPeople[i]+"value: "+(i+1)+", color: "green";
i=i+1;
});
With that script in mind, my idea was to call that array on the resources section of the Scheduler widget as something like this:
resources: [
{
field: "people",
name: "People",
dataSource: [ data: getPeople
]
]
Any ideas or thoughts?
P.S.
I also created some script based on Kendo documentation using Kendo UI Dojo and you can see see exactly the type of view I need there.
To whoever may be interested in the future, I found a way to do this. In a nutshell, very quickly and simple:
resources: [{
field: "Name",
name: "People",
dataTextField: "Name",
dataValueField: "Name",
dataSource: new kendo.data.DataSource({
transport: {
read: {
url: "http://localhost:50379/LoremImpsum-YeahDomainService.svc/json/GetPeople"
}
},
schema: {
type: "json",
data: "GetPeopleResult.RootResults"
}
}
),
multiple: true,
title: "name"
}]
I would like to build a node.js server and use it to retrieve data of a Google Form, like: title, type, options of questions on that form.
e.g.
If I have a Google Form:
http://goo.gl/forms/DSNFS0cfgw
I would like to do somthing like:
var form = getFormData();
// returns
// [
// {title: "Name", type: "text", options:[]},
// {title: "Favorite Season", type: "select", options:["spring", "summer", "autumn", "winter"]},
// {title: "Favorite Fruit", type: "radio", options:["apple", "banana"]}
// ]
Is there a way to do this by using Javascript or any node module?
I don't see a lot of options aside from whipping up cheerio and parsing the HTML source.
Cheerio looks and feels a lot like jQuery, so if you're familiar with that, you shouldn't have a lot of problems.
I haven't had a question from quite a while, but I finally ended up hitting a wall here. Anyways, to make this easy. I am trying to create a JSON store in extjs 3.4 (work related, and no I am not updating).
Well, I created the queries as usual with the proper response and fill it up. My problem is that I have 1 extra property on the JSON that I want to be able to pull and use on the app.
Sample of my JSON from the response object in chrome:
myInventory: [{Priority:1, PMNumber:444, Description:fix-a-tape, Assets:3, Storage_Count:0,…},…]
percent: 97.040498442368
totalCount: "3"
Now, I know this is correctly formatted because the Grid I am using gets populated, but I can't get the percent property. So my question is, how do you pull an extra parameter on the datastore building block of code when you have one extra parameter that is not usual on EXTjs, in my case the percent?
I tried doing a metachange on the JSONReader, but all I get is percent:"percent" on the properties as I inspect the datastore after it's creation.
Ext.data.JsonReader has a property jsonData which is exactly what you need. A quick example:
Ext.onReady(function() {
var store = new Ext.data.JsonStore({
url: 'data/test.json',
root: 'dataRoot',
fields: ['fieldA', 'fieldB'],
idProperty: 'id',
storeId: 'myStore'
});
store.on('load', function(store) {
console.log(store.reader.jsonData.someOtherProperty);
});
store.load();
});
and the data/test.json looks like this:
{
dataRoot: [{
id: 0,
fieldA: 'a',
fieldB: 'b'
}],
someOtherProperty: 'abc'
}
There could also be an alternative approach that you manually (not via store.load()) perform Ext.Ajax request, use the properties you need and then manually call Ext.data.JsonStore.loadData() using the data you got from Ajax request.