how to hide json panel on certain dates - json

Hi I'm beginner in ASP NET, I was asked to hide the "Registration Wizard" panel on 2 weeks before and after certain date. I believe we are using JSon to display panels. I'm not sure how can I achieving this as was unable to find anything.
module PrestigeWorldWide.Scripts.ViewModels {
export class IndexViewModel extends BaseViewModels.BaseViewModel {
public panels: KnockoutObservableArray<IPanelObject> = ko.observableArray<IPanelObject>();
public events: KnockoutObservableArray<FullCalendar.EventObject> = ko.observableArray<any>();
constructor() {
super();
this.panels.push({
Name: "My Transcript",
Desc: "View your unofficial QUB transcript",
Icon: "fa-file-text",
Link: "/PrestigeWorldwide/Grade/ViewTranscript"
});
this.panels.push({
Name: "Module Info",
Desc: "View the information on all modules including pre-requisites and course content",
Icon: "fa-folder-open",
Link: "/PrestigeWorldwide/Module/ModuleInfo"
});
this.panels.push({
Name: "Enrollment Wizard",
Desc: "Enroll for modules and enter further information about yourself - emergency contacts etc.",
Icon: "fa-magic",
Link: "/PrestigeWorldwide/Registration/Index"
});
this.getEvents();
}
getEvents() {
var url = "/PrestigeWorldwide/Class/GetStudentClasses";
this.loading(true);
$.ajax(url).done((events: FullCalendar.EventObject[]) => {
this.loading(false);
_.each(events, (event) => {
this.events.push(event);
});
});
}
}
export interface IPanelObject {
Name: string;
Desc: string;
Icon: string;
Link?: string;
}
}

Simply add a date check before adding the panel:
DateTime cutOffDateStart = new DateTime() // Insert 2 weeks before here
DateTime cutOffDateEnd = new DateTime() // Insert 2 weeks after here
if (DateTime.Now >= cutOffDateStart && DateTime.Now < cutOffDateEnd)
{
panels.Add(new Panel()
{
Name = "Registration Wizard",
Desc = "Use this tool to enrol for the new semester.",
Icon = "fa-pencil"
});
}

Related

How can i integrate paytm in angular4

I'm integrating paytm in angular 4. paytm plugin is successfully added in project , but i don't know how to import paytm plugin in ts file. and call java file file function.
please help me...
here is my code
import { Nav, Platform } from 'ionic-angular';
import { Component, OnInit } from '#angular/core';
import { NavController } from 'ionic-angular';
import {} from 'jasmine';
import {LoginPage} from "../login/login";
import {SignUpPage} from "../signup/signup";
import {HomePage} from "../home/home";
import { Paytm } from '#ionic-paytm/paytm';
#Component({
selector: 'page-apphome',
templateUrl: 'apphome.html'
})
export class AppHomePage implements OnInit {
constructor(public navCtrl: NavController ,public paytm:Paytm) {}
ngOnInit(){
window.plugins.paytm.startPayment("526", "25862", "abc#gmail.com",
"777777777", "25", successCallback, failureCallback);
var userids=window.localStorage.getItem('userid');
//alert(userids);
if(userids!= null)
{
this.navCtrl.push(HomePage);
}
}
}
You can simply archive it.
Create CHECKSUMHASH using backend (.net, php, etc..) with help of API and that just replace checksumhash in form. or you can create form in component itself when you get checksumhash from API.
Create CHECKSUMHASH with help of paytm documentation. STEP 2. and than return CHECKSUMHASH. Take all parameters from frontend.
For Example :
I had used just one button for transaction not needed any form now. after checksumhash i will create form.
app.component.html :
<button type="button" (click)="submitForm()">PAY NOW</button>
app.component.ts :
constructor(private http: HttpClient) { }
// I have all below fields values
paytm = {
MID: "xxxxx", // paytm provide
WEBSITE: "WEBSTAGING", // paytm provide
INDUSTRY_TYPE_ID: "Retail", // paytm provide
CHANNEL_ID: "WEB", // paytm provide
ORDER_ID: "xxxxx", // unique id
CUST_ID: "xxxxx", // customer id
MOBILE_NO: "xxxx", // customer mobile number
EMAIL: "xxxx", // customer email
TXN_AMOUNT: "10.00", // transaction amount
CALLBACK_URL: "http://localhost:4200/paymentverity", // Call back URL that i want to redirect after payment fail or success
};
submitForm() {
// I will do API call and will get CHECKSUMHASH.
this.http.post('https://myAPI.com/createchecksum', this.paytm)
.subscribe((res: any) => {
// As per my backend i will get checksumhash under res.data
this.paytm['CHECKSUMHASH'] = res.data;
// than i will create form
this.createPaytmForm();
};
};
createPaytmForm() {
const my_form: any = document.createElement('form');
my_form.name = 'paytm_form';
my_form.method = 'post';
my_form.action = 'https://securegw-stage.paytm.in/order/process';
const myParams = Object.keys(this.paytm);
for (let i = 0; i < myParams.length; i++) {
const key = myParams[i];
let my_tb: any = document.createElement('input');
my_tb.type = 'hidden';
my_tb.name = key;
my_tb.value = this.paytm[key];
my_form.appendChild(my_tb);
};
document.body.appendChild(my_form);
my_form.submit();
// after click will fire you will redirect to paytm payment page.
// after complete or fail transaction you will redirect to your CALLBACK URL
};
PayTM and PayU both are still on old web service, they still dont support REST so, you will need to prepare the all the params in your web api and then send it as name value array and then bind it to angular page and then either do autopost or manual post
<form ngNoForm #myFormPost name="myFormPost" id="payForm" [action]="postURL" method="POST">
<ng-container *ngFor="let input of apiResponse">
<input *ngIf="!input.multiline" type="hidden" [name]="input.name" [value]="input.value" />
<textarea *ngIf="input.multiline" [name]="input.name" class="textarea--hidden">{{input.value}}</textarea>
</ng-container>
<button (click)="onPost()">Post</button>
</form>
{{input.value}}
Post
{{input.value}}
Post
Dictionary<string, string> dicPam = new Dictionary<string, string>
{
{ "MID", parameters.MID },
{ "CHANNEL_ID", parameters.CHANNEL_ID },
{ "INDUSTRY_TYPE_ID", parameters.INDUSTRY_TYPE_ID},
{ "WEBSITE", parameters.WEBSITE},
{ "EMAIL", parameters.EMAIL},
{ "MOBILE_NO", "9999999999" },
{ "CUST_ID", parameters.CUST_ID },
{ "ORDER_ID", parameters.ORDER_ID },
{ "TXN_AMOUNT", parameters.TXN_AMOUNT},
{ "CALLBACK_URL", parameters.CALLBACK_URL} //This parameter is not mandatory. Use this to pass the callback url dynamically.
};
var payTMParams = _mapper.Map<PayTMParams>(parameters);
payTMParams.CHECKSUMHASH= CheckSum.generateCheckSum(merchantKey, dicPam);
var PayParams = new PaymentParams();
PayParams.PostURL= _configuration.GetSection("PaymentConfig:PayTM:POSTURL").Value;
foreach (var item in dicPam)
{
PayParams.PayParams.Add(new ValPair { Name = item.Key, Value = item.Value });
}
PayParams.PayParams.Add(new ValPair { Name = "CHECKSUMHASH", Value = payTMParams.CHECKSUMHASH });
return PayParams;
Regarding paytm,they are not supporting REST.So it is better to follow ordinary Form submitting Mechanism.so as per their documentation,we can pass the required parameters along with CHECKSUMHASH as ordinary POST request.for that in form
<form ngNoForm method="post"action="https://securegwstage.paytm.in/theia/processTransactio">
ngNoForm
will directly post all data to their gateway.
ShowBillingForm: boolean = true;
PlanId: any;
PlanRes: any = [];
PlanDetail: any = [];
CustomField: boolean = false;
placemntCount: any;
totalPlaceCost: any;
costPerPlace: any;
DiscountAmount: any = 30;
DiscountedAmount: any;
NetAmount: any;
// ************************Paytm Payment Process *********************
RequestedData: any;
responseBilling: any;
EmployerId: any;
timestamp: any;
TransactionFormshow: boolean = false;
RequestDataPay: any;
SubmitBillingDetail() {
this.EmployerId = this.userdetail.id;
this.timestamp = +new Date;
this.timestamp.toString();
this.PlanDetailForm.controls['BillingState'].value
this.RequestedData = {
"name": this.PlanDetailForm.controls.BillingName.value,
"email": this.PlanDetailForm.controls.Billingemail.value,
"contactnum": this.PlanDetailForm.controls.Billingcontactnum.value,
"address": this.PlanDetailForm.controls.Billingaddress.value,
"state": this.PlanDetailForm.controls.BillingState.value,
"district": this.PlanDetailForm.controls.BillingDistrict.value,
"employerid": this.EmployerId,
"cmpid": this.userdetail.companyID,
"createdby": this.EmployerId,
// "order_id": Math.random().toString(36).substr(2, 9),
"order_id": Math.floor(10000000000 + Math.random() * 90000000000),
"transaction_id": '',
"status": 'Pending',
"validfrom":this.PlanDetail.valiD_FROM? moment(this.PlanDetail.valiD_FROM).format('YYYY-MM-DD'):parseInt('null'),
"validto":this.PlanDetail.valiD_TO? moment(this.PlanDetail.valiD_TO).format('YYYY-MM-DD'):parseInt('null'),
"Response_msg": 'Successfull',
"TXN_AMOUNT": this.PlanDetailForm.controls.Amount.value,
"Payment_For": 'REGISTRATION',
"CALLBACK_URL": environment.apiUrl + "Payment/PaymentConfirmation",
};
this.spinnerService.show();
this.authenticationService.SaveBillingDetailforRegistration(this.RequestedData).subscribe(res => {
this.responseBilling = res;
this.PurchaseStatus = this.responseBilling.purchasePlanStatus;
this.TransactionFormshow = true;
this.spinnerService.show();
localStorage.setItem('PurchaseStatus', this.PurchaseStatus);
this.RequestDataPay = {
"MID": this.responseBilling.mid,
"WEBSITE": this.responseBilling.website,
"INDUSTRY_TYPE_ID": this.responseBilling.industrY_TYPE_ID,
"CHANNEL_ID": this.responseBilling.channeL_ID,
"ORDER_ID": this.responseBilling.ordeR_ID,
"CUST_ID": this.responseBilling.cusT_ID,
"MOBILE_NO": this.responseBilling.mobilE_NO,
"EMAIL": this.responseBilling.email,
"TXN_AMOUNT": this.responseBilling.txN_AMOUNT,
"CHECKSUMHASH": this.responseBilling.checksum,
"CALLBACK_URL": this.responseBilling.callbacK_URL
};
this.createPaytmForm();
});
}
createPaytmForm() {
const my_form: any = document.createElement('form');
my_form.name = 'paytm_form';
my_form.method = 'post';
// my_form.action = 'https://securegw-stage.paytm.in/order/process';
my_form.action = this.responseBilling.paytmgatway;
const myParams = Object.keys(this.RequestDataPay);
for (let i = 0; i < myParams.length; i++) {
const key = myParams[i];
let my_tb: any = document.createElement('input');
my_tb.type = 'hidden';
my_tb.name = key;
my_tb.value = this.RequestDataPay[key];
my_form.appendChild(my_tb);
};
document.body.appendChild(my_form);
my_form.submit();
}
As I got some info from http://paywithpaytm.com/developer/discussion/topic/how-to-integrate-paytm-in-angularjs-web-app/, it's clearly written that, paytm doesn’t support for angular js , they only help you in integration and checksum generationlogic and without downloading our SDK it is not possible.
Check https://github.com/Paytm-Payments/Paytm_App_Checksum_Kit_PHP

AngularJS passing Json to controller and displaying in a DevExpress Chart

I have a JsonResult method in my controller. I have pulled in data from my database and set to an object. The method will return this object. I am trying pass this data into AngularJS data source. I would like to display a DevExtreme bar chart. Here is code so far.
AngularJS file:
var app = angular.module('customApp', ['dx']);
app.controller("chartControl", function ($scope, $http) {
$scope.sizeSettings = {
dataSource: 'http://localhost:53640/Home/PostChart',
commonSeriesSettings: {
argumentField: 'product_id',
valueField: "product_id", name: "Product Cost",
type: "bar"
},
seriesTemplate: {
nameField: 'Source',
}
};
});
Home Controller:
public JsonResult PostChart(int product_id)
{
Object prod = null;
using (ProductOrderEntities db = new ProductOrderEntities())
{
var product = db.Products.FirstOrDefault(p => p.product_id == product_id);
prod = new {productID = product.product_id, productName = product.product_name, productPrice = product.product_cost, productDescription = product.product_type};
}
return Json(prod, JsonRequestBehavior.AllowGet);
}
}
HTML
<div ng-app="customApp">
<div ng-controller="chartControl">
</div>
</div>
Seems like you forget add markup for chart:
<div dx-chart="chartOptions"></div>
I've made a simple ASP.NET MVC application here https://www.dropbox.com/s/hk3viceoa2zkyng/DevExtremeChart.zip?dl=0
Open the start page http://localhost:56158/Default1/ to see chart in action.
See more information about using DevExtreme Charts in AngularJS app here http://js.devexpress.com/Documentation/Howto/Data_Visualization/Basics/Create_a_Widget/?version=14_2#Data_Visualization_Basics_Create_a_Widget_Add_a_Widget_AngularJS_Approach
This is how I solved it.
HTML
<div ng-app="customCharts">
<div ng-controller="ChartController">
<div dx-chart="productSettings"></div>
</div>
</div>
AngularJS
var app = angular.module('customCharts', ['dx']);
app.controller("ChartController", function ($scope, $http, $q) {
$scope.productSettings = {
dataSource: new DevExpress.data.DataSource({
load: function () {
var def = $.Deferred();
$http({
method: 'GET',
url: 'http://localhost:53640/Home/PostChart'
}).success(function (data) {
def.resolve(data);
});
return def.promise();
}
}),
series: {
title: 'Displays Product Costs for items in our Database',
argumentType: String,
argumentField: "Name",
valueField: "Cost",
type: "bar",
color: '#008B8B'
},
commonAxisSettings: {
visible: true,
color: 'black',
width: 2
},
argumentAxis: {
title: 'Items in Product Store Database'
},
valueAxis: {
title: 'Dollor Amount'
}
}
})
Controller
public JsonResult PostChart()
{
var prod = new List<Object>();
using (ProductOrderEntities db = new ProductOrderEntities())
{
var product = db.Products.ToList();
foreach (var p in product)
{
var thing = new { Name = p.product_name, Cost = p.product_cost };
prod.Add(thing);
}
}
return Json(prod, JsonRequestBehavior.AllowGet);
}

Unable to sort Dgrid

var CustomGrid = declare([Grid, Keyboard, Selection]);
var questionGrid = new CustomGrid({
store: questionCacheStore,
columns: [
editor({
label: "Questions",
field: "question",
editor: "text",
editOn: "dblclick",
sortable:true})
],
selectionMode: "single",
cellNavigation: false
}, "questions");
I am new to Dgrid. So, please do bear with me .
i was able to populate the dgrid with a JsonStore content. But when i click on the column 'Questions', it doesn't get sorted as in local data store.instead it shows an error Uncaught TypeError: Object [object Object] has no method 'sort'. Is it required to define such a method . If so, how and where should i define it ?
I am not the person to answer your J2EE question. I asked that question recently. The solution that I found was to inject the HttpServletRequest directly. This allowed me access to the query string parameters. From there I was able to get the sort direction (ascending, descending) and column to sort. Hopefully the snippets below will help.
Example Grid Setup
require(["dojo/store/JsonRest", "dojo/store/Memory", "dojo/store/Cache",
"dojo/store/Observable", "dgrid/OnDemandGrid", "dojo/_base/declare", "dgrid/Keyboard",
"dgrid/Selection", "dojo/domReady!"],
function(JsonRest, Memory, Cache, Observable, Grid, declare, Keyboard, Selection) {
var rest = new JsonRest({target:"/POC_Admin/rest/Subcategory/", idProperty: "subcatId"});
var cache = new Cache(rest, new Memory({ idProperty: "subcatId" }));
var store = new Observable(cache);
var CustomGrid = declare([ Grid, Keyboard, Selection ]);
var grid = new CustomGrid({
columns: {
subcatId: "ID",
name: "Name"
},
store: store
}, "grid");
grid.on("dgrid-select", function(event){
// Report the item from the selected row to the console.
console.log("Row selected: ", event.rows[0].data);
});
grid.startup();
});
Example Rest GET
#Context private HttpServletRequest servletRequest;
#GET
#Path("")
#Produces(MediaType.APPLICATION_JSON + ";charset=UTF-8")
public String getSubcategories(#QueryParam("name") String name) throws IOException {
//Respond to a QueryString value.
if (servletRequest.getQueryString() != null && servletRequest.getQueryString().length() > 0) {
String querystringKey = servletRequest.getQueryString();
System.out.println("QSKey = " + querystringKey);
System.out.println("Substr: " + querystringKey.substring(0, 4));
if (querystringKey.length()>4) {
if (querystringKey.substring(0, 4).contains("sort")) {
//We have the sort request.
}
}
}
//Return all results otherwise from your DAO at this point
}

Ember Data: Saving relationships

I need to save a deep object to the server all at once and haven't been able to find any examples online that use the latest ember data (1.0.0-beta.4).
For example, with these models:
(jsfiddle)
App.Child = DS.Model.extend({
name: DS.attr('string'),
age: DS.attr('number'),
toys: DS.hasMany('toy', {async:true, embedded:'always'}),
});
App.Toy = DS.Model.extend({
name: DS.attr('string'),
child: DS.belongsTo('child')
});
And this code:
actions: {
save: function(){
var store = this.get('store'),
child, toy;
child = store.createRecord('child', {
name: 'Herbert'
});
toy = store.createRecord('toy', {
name: 'Kazoo'
});
child.set('toys', [toy]);
child.save();
}
}
It only saves the JSON for the child object but not any of the toys -- not even side loaded:
{
child: {
age: null
name: "Herbert"
}
}
Do I have to manually save the toys too? Is there anyway that I can have it send the following JSON to the server:
{
child: {
age: null
name: "Herbert",
toys: [{
name: "Kazoo"
}]
}
}
Or
{
child: {
age: null
name: "Herbert",
toys: [1]
}
}
See JSFiddle: http://jsfiddle.net/jgillick/LNXyp/2/
The answers here are out of date. Ember Data now supports embedded records, which allows you to do exactly what you're looking to do, which is to get and send the full object graph in one big payload. For example, if your models are set up like this:
App.Child = DS.Model.extend({
name: DS.attr('string'),
age: DS.attr('number'),
toys: DS.hasMany('toy')
});
App.Toy = DS.Model.extend({
name: DS.attr('string'),
child: DS.belongsTo('child')
});
You can define a custom serializer for your Child model:
App.ChildSerializer = DS.RESTSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
toys: {embedded: 'always'}
}
});
This tells Ember Data that you'd like 'toys' to be included as part of the 'child' payload. Your HTTP GET response from your API should look like this:
{
"child": {
"id": 1,
"name": "Todd Smith",
"age": 5,
"toys": [
{"id": 1, "name": "boat"},
{"id": 2, "name": "truck"}
]
}
}
And when you save your model, Ember Data will send this to the server:
{
"child":{
"name":"Todd Smith",
"age":5,
"toys":[
{
"id":"1",
"name":"boat",
"child":"1"
},
{
"id":"2",
"name":"truck",
"child":"1"
}
]
}
}
Here is a JSBin that demonstrates this.
http://emberjs.jsbin.com/cufaxe/3/edit?html,js,output
In the JSbin, when you click the 'Save' button, you'll need to use the Dev Inspector to view the request that's sent to the server.
toys can't be both async and embedded always, those are contradicting options. Embedded only exists on the active model serializer currently.
toys: DS.hasMany('toy', {embedded:'always'})
the toys are a ManyToOne relationship, and since the relationship exists on the belongsTo side it is more efficient to save the relationship during the toy's save. That being said, if you are creating it all at once, then want to save it in one big chunk that's where overriding comes into play.
serializeHasMany: function(record, json, relationship) {
var key = relationship.key;
var relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany' ||
relationshipType === 'manyToOne') {
json[key] = get(record, key).mapBy('id');
// TODO support for polymorphic manyToNone and manyToMany relationships
}
},
And your save should be like this
var store = this.get('store'),
child, toy;
child = store.createRecord('child', {
name: 'Herbert'
});
toy = store.createRecord('toy', {
name: 'Kazoo'
});
child.get('toys').pushObject(toy);
child.save().then(function(){
toy.save();
},
function(err){
alert('error', err);
});
I needed a deep object, instead of a side-loaded one, so based on kingpin2k's answer, I came up with this:
DS.JSONSerializer.reopen({
serializeHasMany: function(record, json, relationship) {
var key = relationship.key,
property = Ember.get(record, key),
relationshipType = DS.RelationshipChange.determineRelationshipType(record.constructor, relationship);
if (property && relationshipType === 'manyToNone' || relationshipType === 'manyToMany' ||
relationshipType === 'manyToOne') {
// Add each serialized nested object
json[key] = [];
property.forEach(function(item, index){
json[key].push(item.serialize());
});
}
}
});
Now when you call child.serialize(), it will return this object:
{
child: {
name: "Herbert",
toys: [
{
name: 'Kazoo'
}
]
}
}
Which is what I need. Here's the jsfiddle with it in action: http://jsfiddle.net/jgillick/LNXyp/8/

Sencha Touch searchable list -- new view with data proxy

Two quick questions here... How can I use this example
http://try.sencha.com/touch/2.0.0/examples/list-search/
of a searchable list, but opened in a NEW view? The example has it defined as the main application in app.js, but I would like to use it in "FirstApp.view.searchlist"
I know the answer is pretty easy but I am still a young grasshoppa and need a push in the right direction.
Also, rather than pulling the data from the embedded store like the example, I would like to modify it to pull my data from my external/proxy JSON store, which is defined as follows:
Store:
Ext.define('FirstApp.store.StudentStore',{
extend:'Ext.data.Store',
config:{
autoLoad:true,
model:'FirstApp.model.people',
sorters: 'lastName',
proxy:{
type:'ajax',
url:'http://xxxyyyzzz.com/data/dummy_data.json',
reader:{
type:'json',
rootProperty:'results'
}
}
}
});
Model:
Ext.define('FirstApp.model.people', {
extend: 'Ext.data.Model',
config: {
fields: ['firstName', 'lastName' , 'image','status', 'phone','rank','attendance', 'discipline','recent']
}
});
So, how can I turn that example into a "view" inside my application, with my data store and model?
Any help is greatly appreciated! Thank you!
Jake
-----------UPDATE-------------
Ok fantastic. I was able to implement the search feature (stoked) by combining your methods with another tutorial I found. Now one more question...Seems so easy but it is tough! How can I open my new 'Details' view once an item is selected/clicked ??
Search list:
Ext.define('FirstApp.view.MainPanel', {
extend: 'Ext.dataview.List',
alias : 'widget.mainPanel',
config: {
store : 'Students',
itemTpl:
'<h1>{firstName:ellipsis(45} {lastName:ellipsis(45)}</h1>' ,
itemCls:'place-entry',
items: [
{
xtype: 'toolbar',
docked: 'top',
items: [
{
xtype: 'searchfield',
placeHolder: 'Search People...',
itemId: 'searchBox'
}
]
}
]
}
});
Details view (that I want to open when name is clicked from Search list/Mainpanel view):
Ext.define('FirstApp.view.Details',{
extend:'Ext.Panel',
xtype:'details',
config:{
layout:'fit',
tpl:'<div class="image_container"><img src="{image}"></div>' +
'<h1>{firstName:ellipsis(25)} {lastName:ellipsis(25)}</h1>'+
'<div class="status_container">{status:ellipsis(25)}</div> '+
'<div class="glance_container"> <div class="value_box"><div class="value_number"> {rank:ellipsis(25)}</div> <p class="box_name">Rank</p> </div> <div class="value_box"><div class="value_number"> {attendance:ellipsis(25)}</div> <p class="box_name" style="margin-left: -10px;">Attendance</p> </div> <div class="value_box"><div class="value_number">{discipline:ellipsis(25)}</div> <p class="box_name" style="margin-left: -4px;">Discipline</p> </div> <div class="value_box"><div class="value_number"> {recent:ellipsis(25)}</div> <p class="box_name">Recent</p> </div> </div> '+
'<h2>Phone:</h2> <div class="phone_num"><p>{phone:ellipsis(25)}</p></div>'+
'<h3>Some info:</h3><p>Round all corners by a specific amount, defaults to value of $default-border-radius. When two values are passed, the first is the horizontal radius and the second is the vertical radius.</p>',
scrollable:true,
styleHtmlContent:true,
styleHtmlCls:'details'
}
})
Search Controller:
Ext.define('FirstApp.controller.SearchController', {
extend : 'Ext.app.Controller',
config: {
profile: Ext.os.deviceType.toLowerCase(),
stores : ['StudentStore'],
models : ['people'],
refs: {
myContainer: 'MainPanel',
placesContainer:'placesContainer'
},
control: {
'mainPanel': {
activate: 'onActivate'
},
'mainPanel searchfield[itemId=searchBox]' : {
clearicontap : 'onClearSearch',
keyup: 'onSearchKeyUp'
},
'placesContainer places list':{
itemtap:'onItemTap'
}
}
},
onActivate: function() {
console.log('Main container is active');
},
onSearchKeyUp: function(searchField) {
queryString = searchField.getValue();
console.log(this,'Please search by: ' + queryString);
var store = Ext.getStore('Students');
store.clearFilter();
if(queryString){
var thisRegEx = new RegExp(queryString, "i");
store.filterBy(function(record) {
if (thisRegEx.test(record.get('firstName')) ||
thisRegEx.test(record.get('lastName'))) {
return true;
};
return false;
});
}
},
onClearSearch: function() {
console.log('Clear icon is tapped');
var store = Ext.getStore('Students');
store.clearFilter();
},
init: function() {
console.log('Controller initialized');
},
onItemTap:function(list,index,target,record){ // <-----NOT WORKING
this.getPlacesContainer().push({
xtype:'details',
store:'Students',
title:record.data.name,
data:record.data
})
}
});
Good question. I assume you are trying to build a List or dataview. The key here is to give your store a 'storeId'. I have modified your store below:
Ext.define('FirstApp.store.StudentStore',{
extend:'Ext.data.Store',
config:{
storeId: 'Students', // Important for view binding and global ref
autoLoad:true,
model:'FirstApp.model.people',
sorters: 'lastName',
proxy:{
type:'ajax',
url:'http://xxxyyyzzz.com/data/dummy_data.json',
reader:{
type:'json',
rootProperty:'results'
}
}
}
});
Then inside your view, you reference the store to bind to. Here is an example List view from one of my applications. Notice the config object has 'store' which references our above store:
Ext.define('app.view.careplan.CarePlanTasks', {
extend: 'Ext.dataview.List',
xtype: 'careplanTasks',
requires: [
'app.view.template.CarePlan'
],
config: {
store: 'Students', // Important! Binds this view to your store
emptyText: 'No tasks to display',
itemTpl: Ext.create('app.view.template.CarePlan'),
},
constructor : function(config) {
console.log('CarePlan List');
this.callParent([config]);
}
});
Now that you have a storeId, you can access this store anywhere in your application by doing the following:
Ext.getStore('Students')
You can load records from your server by calling the load method as well:
Ext.getStore('Students').load();
You can do this anywhere in your application, but typically it's best to do in your controllers.
Hope this helps.
======= Updates to your updates ======
So looking at your code I think you need to modify your List view and the controller. Give 'FirstApp.view.MainPanel' an xtype: 'MainPanel'. Next modify your controller config as follows:
config: {
profile: Ext.os.deviceType.toLowerCase(),
stores : ['StudentStore'],
models : ['people'],
refs: {
mainPanel: 'MainPanel', // set the object KEY to the name you want to use in the control object and set the VALUE to the xtype of the view
placesContainer:'placesContainer'
},
control: {
'mainPanel': { // this matches the key above, which points to your view's xtype
activate: 'onActivate',
itemtap: 'onItemTap' // listen for the item tap event on this List
},
'mainPanel searchfield[itemId=searchBox]' : {
clearicontap : 'onClearSearch',
keyup: 'onSearchKeyUp'
},
'placesContainer places list':{
itemtap:'onItemTap'
}
}
},