Im using KendoUI, AnduglarJS in ASP.NET MVC 4.
Im trying get data and show in grid, but my grid is not showing data.
Data is downloaded from db and I have they in js.
list.cshtml
<div class="panel panel-default" ng-controller="app.views.register.list as vm">
<div kendo-grid k-data-source="vm.registers" k-selectable="'row'"
k-pageable='{ "refresh": true, "pageSizes": true }'
k-on-change="vm.handleChange(kendoEvent)"
k-columns='[
{ "field": "type", "title": "Typ"},
{ "field": "status", "title": "Status"},
{ "field": "ip", "title": "IP"},
{ "field": "description", "title": "Opis"},
{ "field": "createdDate", "title": "Data utworzenia", type: "datetime", format: "{0:d}"}
]'>
</div>
</div>
list.js
(function () {
var app = angular.module('app');
var controllerId = 'app.views.register.list';
app.controller(controllerId, [
'$scope', '$location', 'abp.services.app.register',
function ($scope, $location, registerService) {
var vm = this;
var localize = abp.localization.getSource('Ebok');
//kendo.culture("en-EN");
vm.handleChange = function (kendoEvent) {
var grid = kendoEvent.sender;
var selectedData = grid.dataItem(grid.select());
var id = selectedData.id;
vm.changeRegister(id);
}
vm.registers = new kendo.data.ObservableArray([]);
registerService.getRegisters({ PageSize: 20 }).success(function (data) {
vm.registers = new kendo.data.ObservableArray(data.registers);
});
}
]);
})();
In vm.registers I have data, here is example:
{"type":"dfdgf","status":"dfdrf","ip":"dfdf","description":"cdsdfsdfs666","createdDate":"2014-12-29T12:09:55.16","id":1}
What is wrong?
Problem was in configuration.
In file app.js I dont have one line 'kendo.directives'
var app = angular.module('app', [
'ngAnimate',
'ngSanitize',
'ui.router',
'ui.bootstrap',
'ui.jq',
'abp',
'kendo.directives'
]);
Related
I am trying to implement the List template feature of Alexa skill kit. However, I am unable to return the response in an appropriate format.
I have implemented the feature using the official documentation. However, I am not getting how to return the response of list template to my custom intent
'ListTemplate':function(){
var title = "This is a sample list";
var speechOutput = "Showing the sample list";
var template = {
"type":"Display.RenderTemplate",
"template":{
"type":"ListTemplate1",
"token":"ListTemplate",
"title":title,
"backButton":"VISIBLE",
"backgroundImage":{
"contentDescription":"backgroundImage",
"sources":[
{
"url":"https://democard.s3.amazonaws.com/hostel-720.jpg"
}]
},
"listItems":[{
"token":"item1",
"image":{
"sources":[{
"url":"https://democard.s3.amazonaws.com/c-v-raman-college-of-engineering-squarelogo-1534916004379+(3).jpg"
}],
"contentDescription":"first item of list"
},
"textContent":{
"primaryText":{
"type":"PlainText",
"text":"primary Text is here"
},
"secondaryText":{
"type":"PlainText",
"text":"Secondary text is here"
}
},
},
{
"token":"item2",
"image":{
"sources":[{
"url":"https://democard.s3.amazonaws.com/c-v-raman-college-of-engineering-squarelogo-1534916004379+(3).jpg"
}],
"contentDescription":"second item"
},
"textContent":{
"primaryText":{
"type":"PlainText",
"text":"primary text is here"
},
"secondaryText":{
"type":"PlainText",
"text":"secondary text"
}
}
}
]
}};
var directives =[ template ];
//return build_speechlet_response(title,speechOutput,directives, SESSION_LIST);
// function
build_speechlet_response(title,speechOutput,directives,phase){
const response = {
"version": "1.0",
"response": {
"outputSpeech":{
"type":"PlainText",
"text":"what else would you like to see"
},
"card":{
'type':'Simple',
'title':title,
'content':speechOutput
},
"directives":directives,
"shouldEndSession":'False'
},
"sessionAttributes":{
"template":"list_"
}
};
// return response;
this.emit(':tell',response);
},
The response I should get must be a custom list. But I am not getting it
It looks like this issues is that response is an object. It should be something like this.emit(':tell', speechOutput) (where speechOutput is a string).
If you want to also send a card it's this.emit(':tellWithCard', speechOutput, cardTitle, cardContent, imageObj).
But, since you're trying to use a render template, it would be something like:
this.response.speak(speechOutput)
.cardRenderer(cardTitle, cardContent, cardImage)
.renderTemplate(template);
this.emit(':responseReady');
You can find more info here - https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/tree/1.x
I do notice you're using v1 of the SDK - I would really recommend using v2 as it's a lot more straight forward.
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
Hope that helps.
I tried the following code yet the response was not rendered.
const DisplayListIntentHandler = {
canHandle(handlerInput){
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'DisplayList';
},
handle(handlerInput){
var title = "This is a sample list";
var speechOutput = "Showing the sample list";
var template = {
type:'Display.RenderTemplate',
template:{
type:"ListTemplate1",
token:"ListTemplate",
title:'title',
backButton:"VISIBLE",
backgroundImage:{
contentDescription:"backgroundImage",
sources:[
{
url:"https://democard.s3.amazonaws.com/hostel-720.jpg"
}]
},
listItems:[{
token:"item1",
image:{
sources:[{
url:"https://democard.s3.amazonaws.com/c-v-raman-college-of-engineering-squarelogo-1534916004379+(3).jpg"
}],
contentDescription:"first item of list"
},
textContent:{
primaryText:{
type:"PlainText",
text:"primary Text is here"
},
secondaryText:{
type:"PlainText",
text:"Secondary text is here"
}
},
},
{
token:"item2",
image:{
sources:[{
url:"https://democard.s3.amazonaws.com/c-v-raman-college-of-engineering-squarelogo-1534916004379+(3).jpg"
}],
contentDescription:"second item"
},
textContent:{
primaryText:{
type:"PlainText",
text:"primary text is here"
},
secondaryText:{
type:"PlainText",
text:"secondary text"
}
}
}
]
}};
return handlerInput.responseBuilder
.addRenderTemplateDirective(template)
.getResponse();
}
};
I am attempting to pass values from a Suitelet to an HTML page that is being inserted into an INLINEHTML field in the Suitelet form. However, I am unsure of the best way to accomplish this. I am currently doing it in this manner, but I want to ensure that I am using a somewhat secure method ideally, as opposed to allowing for XSS vulnerabilities.
Suitelet INLINEHTML field:
var htmlForm = form.addField({
id: 'custpage_htmlform',
type: ui.FieldType.INLINEHTML,
label: 'HTMLFORM'
});
var fileObj = file.load({
id: 123
});
var htmlContent = fileObj.getContents();
htmlContent = htmlContent.replace("['REPLACETHIS']","['<input type=\"radio\" name=\"selectRow\" />','EXAMPLE','1234','1245','01/2021','<img src=\"https://imageurl.example" />'];");
htmlForm.defaultValue = htmlContent;
HTML example:
<table id="example" class="display" style="width:100%">
</table>
<br />
<script>
//Main Data Table
var exampleValues = new Array();
var exampleDetailArr = ['REPLACETHIS'];
exampleValues.push(exampleDetailArr);
window.$vars = {
exampleValues: exampleValues
}
$(document).ready(function() {
$('#example').DataTable( {
data: exampleValues,
"bJQueryUI": true,
columns: [
{ title: "Select" },
{ title: "Type" },
{ title: "Internal ID" },
{ title: "External ID "},
{ title: "Date" },
{ title: "Memo" },
],
"columnDefs": [
{
"targets": [ 3 ],
"visible": false,
"searchable": false
}
]
} );
} );
</script>
This is the DynamoDB table structure I'm working on:
{
"userId": "99999999-9999-9999-9999-999999999999",
"userProfile": {
"email": "myemail#gmail.com",
"firstName": "1234124",
"lastName": "123423",
},
"masterCards": [
{
"cardId": 101000000000001,
"cardImage": "logo.png",
"cardName": "VipCard1",
"cardWallet": "0xFDB17d12057b6Fe8c8c425D2DB88d8475674567"
},
{
"cardId": 102000000000002,
"cardImage": "logo.png",
"cardName": "VipCard2",
"cardWallet": "0xFDB17d12057b6Fe8c8c425D2DB88d8183454345"
},
{
"cardId": 103000000000003,
"cardImage": "logo.png",
"cardName": "VipCard3",
"cardWallet": "0xFDB17d12057b6Fe8c8c425D2DB88d8184345345"
}
],
}
I'm trying to increase the cardId field by one for the first list item with this Lambda function:
const dynamoDB = new AWS.DynamoDB({region: 'eu-central-1', apiVersion:'2012-08-10'});
const counterId="99999999-9999-9999-9999-999999999999"
const params = {
TableName:"FidelityCardsUsers",
Key: {"userId":{"S":counterId}},
UpdateExpression:"ADD #masterCards[0].#cardId :increment",
ExpressionAttributeNames:{
"#masterCards": "masterCards",
"#cardId": "cardId"
},
ExpressionAttributeValues:{":increment": {"N": "1"}}
}
dynamoDB.updateItem(params, function(err, data) {
if (err) {
console.log('error getting counter from DynamDB: ',err)
callback(err);
} else {
callback(null,data)
}
})
In return I get only a new top-level attribute named "mastercards[0].cardId[0]" with a value number set to 1.
I have tried to increment In an array and its work fine with AWS.DynamoDB.DocumentClient()
Example :
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
let params = {
TableName:'tableName',
Key: {
'venueId': 'VENUE_002'
},
UpdateExpression: "ADD #walk.#coordinates[0] :increment",
ExpressionAttributeNames: {
'#walk': 'walk',
'#coordinates': 'coordinates'
},
ExpressionAttributeValues: {
':increment': 1 // This is from the client
},
ReturnValues: 'UPDATED_NEW'
};
docClient.update(params, function (err, data) {
if (err) {
console.log('failure:updateShuttleDirection:failed');
console.log(err);
} else {
console.log('success:updateShuttleDirection:complete');
console.log(data);
}
});
Sample Data:
"walk": {
"coordinates": [
10,
20
],
"type": "Point"
},
I have tried to increment 10 to 11 and its work fine
Reading the doc here, it seems that:
the ADD action can only be used on top-level attributes, not nested
attributes.
This is the structure of nested array:
$scope.History = [
{
isCustomer:false,
userText:"some text",
options:[]
}
The array with data:
//The text in DisplayLabel will be the same for all the objects.
$scope.Categories = [
{ "QuestionId": 1, "QuestionName": "Complaint", "DisplayLabel": "what is it?" },
{ "QuestionId": 2, "QuestionName": "Registration", "DisplayLabel": "what is it?" }
];
Desired Array:
$scope.History = [
{
isCustomer:false,
userText:"what is it?",
options:["Complaint","Registration"]
}
Normally I would do this for a 1D array
angular.forEach($scope.Categories, function (value, key) {
$scope.History.push(false,value.DisplayLabel);
Now, how to add items to 'options' for an object.
EDIT:
I tried this but no luck. Doesn't display any data
var optionsData = [];
var userText = "";
angular.forEach($scope.Categories, function (value, key) {
optionsData.push(value.QuestionName);
userText = value.DisplayLabel;
})
$scope.History.push(false,userText,optionsData);
var app = angular.module('app', []);
app.controller('homeCtrl', function($scope) {
$scope.History = [{
isCustomer: false,
userText: "some text",
options: []
}]
$scope.Categories = [{
"QuestionId": 1,
"QuestionName": "Complaint",
"DisplayLabel": "what is it?"
}, {
"QuestionId": 2,
"QuestionName": "Registration",
"DisplayLabel": "what is it?"
}];
var optionsData = []
angular.forEach($scope.Categories, function(value, key) {
$scope.History[0].options.push(value.QuestionName)
});
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<div ng-app="app">
<div ng-controller="homeCtrl">
<pre>{{History | json}}</pre>
</div>
</div>
I'm trying to validate my inputs from a form with BreezeJS / KnockoutJS / Durandal and I'm not getting any results.
This is my input inside my view:
<input data-bind="value:app_name, attr: {placeholder: resources.brand_create_placeholder_brand_name }" type="text" class="form-control input-sm" name="app_name" id="app_name" />
And this is my viewmodel:
define(['durandal/app', 'services/logger', 'plugins/router', 'knockout', 'breeze', 'toastr', 'services/resources'],
function (app, logger, router, ko, breeze, toastr, resourcesSVC) {
var vm = {
app_name: ko.observable(), //.extend({ required: true, minLength: 30, }),
...,
currency: ko.observable(),
currencies: [{ name: "Euro", value: "EUR", synbol: "€" }, { name: "Dollar", value: "USD", synbol: "$" }, { name: "Pounds Sterling", value: "GBP", synbol: "£" }],
use_smtp: ko.observable(false),
activate: activate,
title: "Create Brand",
createEntity: createEntity,
goBack: goBack,
resources: {}
}
};
Here I'm initializing my service:
var serviceName = 'breeze';
var manager = new breeze.EntityManager(serviceName);
And here I have the creation of my entity:
function createEntity() {
var DT = breeze.DataType;
var Validator = breeze.Validator;
var brand = manager.metadataStore.getEntityType("app");
/*app_name*/
var propAppName = brand.getProperty('app_name');
brand.addValidator(Validator.required(), propAppName);
brand.addValidator(Validator.maxLength({ maxLength: 30 }), propAppName);
var newBrand = brand.createEntity('app');
newBrand.app_name = vm.app_name();
...
manager.addEntity(newBrand);
manager.saveChanges()
.then(createSucceeded)
.fail(createFailed);
function createSucceeded(data) {
toastr.success("Brand created");
app.trigger('brand:changed');
router.navigate('#brands');
}
function createFailed(error) {
var msgError = "Create failed: " + getErrorMessages(error);
toastr.error(msgError);
manager.rejectChanges();
}
}
Can you please help me set validators for each field & display a custom message for each one whose values aren't correct?
Thank you!