I am trying to figure out a basic implementation of infinite scrolling in a ExtJs 4.1.0 grid.
I am working off this example http://ext4all.com/post/extjs-4-1-grid-infinite-scroll-in-mvc and at this point my code is practically identical to the example.
When my page loads, the grid is filled with the first page of data as the first ajax request fires and works as expected. However, when I scroll down to the bottom of the grid, nothing happens... I am expecting to see an ajax request fire, grabbing additional data (as in the example).
Any ideas?
Here is my code:
HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="./extjs-4.1.0/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="./styles.css">
<script type="text/javascript" src="./extjs-4.1.0/ext-all-debug.js"></script>
<script type="text/javascript" src="./test-scrolling.js"></script>
</head>
<body>
<div id="page">
<header>
<div class='wrap'>
<h1>Test</h1>
<div class='clear'></div>
</div>
</header>
<div class="content">
<div class="wrap">
<div id="main"></div>
</div>
</div>
</div>
</body>
</html>
Javascript
Ext.define('AP.model.Log', {
extend: 'Ext.data.Model',
fields: [
'Id',
'ProcessId',
'IndexRequest',
'AssetIndexStart',
'AssetIndexEnd',
'StartDate',
'EndDate']
});
Ext.define('AP.store.Log', {
extend: 'Ext.data.Store',
model: 'AP.model.Log',
autoLoad: true,
remoteSort: true,
buffered: true,
pageSize: 100,
proxy: {
type: 'ajax',
url: 'http://localhost/...',
limitParam: 'limit',
reader: {
type: 'json',
root: 'Log',
successProperty: 'Success'
}
}
});
Ext.define('AP.view.Log', {
extend: 'Ext.grid.Panel',
alias: 'widget.log',
title: 'Log',
store: 'Log',
initComponent: function () {
this.columns = [{
header: 'Index Start',
dataIndex: 'AssetIndexStart',
flex: 1
}, {
header: 'Index End',
dataIndex: 'AssetIndexEnd'
}, {
header: 'Start Date',
dataIndex: 'StartDate'
}, {
header: 'End Date',
dataIndex: 'EndDate'
}];
this.callParent(arguments);
}
});
Ext.define('AP.controller.Log', {
extend: 'Ext.app.Controller',
stores: ['Log'],
models: ['Log'],
views: ['Log'],
init: function () {}
});
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'AP',
appFolder: 'app',
controllers: [
'Log'],
launch: function () {
Ext.widget('log', {
title: 'Log',
width: 600,
height: 400,
renderTo: 'main'
});
}
});
Related
Data is not getting loaded in JqGrid from controller in ASP.NET Core.
I tried two ways, you can see two different methods in controller which I tried.
What am I doing wrong?
Index.cshtml
<link rel="stylesheet" href="/css/ui.jqgrid.css" />
<link rel="stylesheet" href="/css/jquery-ui.css" />
<script type="text/javascript" src="/js/grid.locale-en.js"></script>
<script type="text/javascript" src="/js/jquery.jqGrid.min.js"></script>
<table id="jqGrid"></table>
<div id="jqGridPager"></div>
#section scripts {
<script type="text/javascript">
$(document).ready(function () {
$("#jqGrid").jqGrid({
url:'#Url.Action("Index", "Maintenance")',
mtype: "POST",
datatype: "json",
colModel: [
{ label: 'Badge', name: 'Badge', key: true, width: 75 },
{ label: 'User ID', name: 'User', width: 150 },
{ label: 'EmailAddress', name: 'EmailAddress', width: 150 },
{ label: 'FULL_NAME_PREFERRED', name: 'FULL_NAME_PREFERRED', width: 150 },
{ label: 'Active', name: 'Active', width: 150 }
],
viewrecords: true,
width: 780,
height: 250,
rowNum: 20,
pager: "#jqGridPager"
});
});
</script>
}
MaintenanceController
Way 1
public IActionResult Index()
{
var lstMaintenanceModels = repos.GetUsers();
return View(lstMaintenanceModels);
}
Way 2
public JsonResult Index()
{
var lstMaintenanceModels = repos.GetUsers();
return Json(lstMaintenanceModels);
}
Starup.cs
services.AddControllers().AddNewtonsoftJson(options =>
{
// Use the default property (Pascal) casing
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});
Output what i am getting right now
Way 1
Way 2
You need to write all js code in #section Scripts{}, Because the key in the json returned by the controller is lowercase, and what you wrote here is uppercase, it cannot be received. So in page you need to wirte like this :
The page needs to receive the value of json type, so you need to use the second method, or return the model directly, the program will automatically serialize it to json.
Code
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" integrity="sha512-aOG0c6nPNzGk+5zjwyJaoRUgCdOrfSDhmMID2u4+OIslr0GjpLKo7Xm0Ao3xmpM4T8AmIouRkqwj1nrdVsLKEQ==" rel="stylesheet"></link>
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/css/ui.jqgrid.min.css" integrity="sha512-xAIWSSbGucVRdutqUD0VLDowcMF/K8W87EbIoa9YUYB4bTyt/zeykyuu9Sjp0TPVdgrgGgBVCBowKv46wY5gDQ==" rel="stylesheet"></link>
<link crossorigin="anonymous" href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/plugins/css/ui.multiselect.min.css" integrity="sha512-UuhJihFIXhnP4QEzaNXfLmzY9W3xoeTDATm0buV4wb2qJKoikNn568f0zA5QmrX0sp6VZzqE6fffvsTYU34tGA==" rel="stylesheet"></link>
<table id="dataTable"></table>
<div id="pager"></div>
#section Scripts
{
<script crossorigin="anonymous" integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA==" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script crossorigin="anonymous" integrity="sha512-xt9pysburfYgFvYEtlhPDo8qBEPsupsDvWB8+iwspD+oQTvAdDEpA1aIKcH6zuABU528YitH6jtP0cAe5GrwKA==" src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.15.5/jquery.jqgrid.min.js"></script>
<script>
jQuery("#dataTable").jqGrid({
url:'#Url.Action("GetUsers", "Home")',
datatype: "json",
mtype: 'POST',
//here name must be
colModel: [
{ label: 'Badge', name: 'badge', key: true, width: 75 },
{ label: 'User ID', name: 'user', width: 150 },
{ label: 'EmailAddress', name: 'emailAddress', width: 150 },
{ label: 'FULL_NAME_PREFERRED', name: 'fulL_NAME_PREFERRED', width: 150 },
{ label: 'Active', name: 'active', width: 150 }
],
loadonce: true,
width: 780,
height: 250,
rowNum: 20,
pager: "#pager"
});
</script>
}
If the parameter datatype is 'json', jqGrid expects the following default format for JSON data
{
"total": "xxx",
"page": "yyy",
"records": "zzz",
"rows" : [
{"id" :"1", "cell" :["cell11", "cell12", "cell13"]},
{"id" :"2", "cell":["cell21", "cell22", "cell23"]},
]
}
You can read about this there^
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data
Try this:
return Json(new { rows = repos.GetUsers() } );
Is there a way to implement a Defect Suite Popover within a Rally Grid that allows for viewing Defect Suites associated with a Defect? Currently, only the count of Defect Suites for a given Defect seems available.
This one took a little bit of tinkering, but here's what I came up with. I included the full app because there are a few moving parts. Basically this setup mirrors the way the other existing popovers are built (Defects, Tasks, etc.)
First we define a popover. I borrowed code from the TaskPopover as a starting point and then updated the parentProperty and childField configs near the bottom and changed the columns to be shown.
Next we define a status template to render the defect suite count in the grid. Again, I borrowed code from the TaskStatusTemplate as a starting point and just tweaked it a little bit to show the right data. There is some css at the bottom of the app to style it as well.
Finally, in the sample app included I add a grid of defects that all contain defect suites to test it. There are two little overrides at the beginning of the launch method to completely wire up the popover.
Hope that gets you started!
<!DOCTYPE html>
<html>
<head>
<title>DefectSuitePopover</title>
<script type="text/javascript" src="/apps/2.0/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function () {
//
//Define the popover
//
Ext.define('DefectSuitePopover', {
alias: 'widget.defectsuitepopover',
extend: 'Rally.ui.popover.ListViewPopover',
title: 'Defect Suites',
titleIconCls: 'icon-defect-suite',
width: 700,
constructor: function (config) {
config.listViewConfig = Ext.merge({
gridConfig: {
addNewConfig: {},
columnCfgs: [
{
dataIndex: 'FormattedID',
width: 90
},
{
dataIndex: 'Name',
flex: 1
},
{
dataIndex: 'Owner',
width: 90
},
{
dataIndex: 'ScheduleState',
width: 55
}
],
storeConfig: {
context: config.context
}
},
model: Ext.identityFn('DefectSuite'),
parentProperty: 'Defects',
childField: 'DefectSuites'
}, config.listViewConfig);
this.callParent(arguments);
}
});
//
//Define the status template for the grid to launch the popover
//
Ext.define('DefectSuitesStatusTemplate', {
extend: 'Rally.ui.renderer.template.status.StatusTemplate',
inheritableStatics: {
onClick: function(event, ref) {
Rally.ui.renderer.template.status.StatusTemplate.onClick(event, ref, {
field: 'DefectSuite',
target: event.target,
targetSelector: 'a.id-' + Rally.util.Ref.getOidFromRef(ref)
});
}
},
constructor: function() {
this.callParent([
'<tpl if="this._getCount(values) > 0">',
'<a class="defect-suites-count id-{[values.ObjectID]}" onclick="{[this._getOnClick(values)]}">',
'{[this._getCount(values)]}',
'</a>',
'</tpl>'
]);
},
_getCount: function (recordData) {
return recordData.DefectSuites.Count;
},
_getOnClick: function(recordData) {
return 'DefectSuitesStatusTemplate.onClick(event, \'' + recordData._ref + '\'); return false;';
}
});
//
//Define the app
//
Ext.define('DefectSuitePopoverApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
//Add the new status template
Rally.ui.renderer.RendererFactory.fieldTemplates.defectsuites = function() {
return Ext.create('DefectSuitesStatusTemplate');
};
//Register the popover
Rally.ui.popover.PopoverFactory.popovers.DefectSuite = function(config) {
return Ext.create('DefectSuitePopover', config);
};
//Add grid
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
'Owner',
{
dataIndex: 'DefectSuites',
align: 'center'
},
'Tasks',
'State'
],
context: this.getContext(),
enableEditing: false,
showRowActionsColumn: false,
storeConfig: {
model: 'defect',
filters: [{
property: 'DefectSuites.ObjectID',
operator: '!=',
value: null
}]
}
});
}
});
Rally.launchApp('DefectSuitePopoverApp', {
name:"DefectSuitePopover",
parentRepos:""
});
});
</script>
<style type="text/css">
.app a.defect-suites-count {
cursor: pointer;
color: #337ec6;
}
</style>
</head>
<body>
</body>
</html>
I would like to filter User Stories for each Project I have in Rally and not just for the one that is currently selected. Is it possible?
This code uses rallyprojectpicker and refreshes the grid based on the project selection:
<!DOCTYPE html>
<html>
<head>
<title>Stories By Project</title>
<script type="text/javascript" src="https://rally1.rallydev.com/apps/2.0rc1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
items: [
{
xtype: 'container',
itemId: 'projFilter'
},
{
xtype: 'container',
itemId: 'grid'
}
],
launch: function() {
this.down('#projFilter').add({
xtype: 'rallyprojectpicker',
itemId: 'projPicker',
workspace: '/workspace/12352608129',
value: '/project/12527515559', //default
listeners: {
change: this._onProjectChange,
scope: this
}
});
},
_onProjectChange: function()
{
if(!this.model) {
this._retrieveModel();
} else {
this._refreshGrid();
}
},
_retrieveModel: function(comboBox) {
Rally.data.ModelFactory.getModel({
type:'UserStory',
success:this._onModelRetrieved,
scope: this
});
},
_refreshGrid: function() {
this.grid.reconfigure(this._buildStore());
},
_buildStore: function() {
return Ext.create('Rally.data.WsapiDataStore', {
model: this.model,
autoLoad: true,
context: {
projectScopeUp: false,
projectScopeDown: false,
project: this.down('#projPicker').getValue()
}
});
},
_onModelRetrieved: function(model) {
this.model = model;
this.grid = this.down('#grid').add({
xtype:'rallygrid',
store: this._buildStore(),
columnCfgs:[
'FormattedID',
'Name'
]
});
}
});
Rally.launchApp('CustomApp', {
name: 'Stories By Project'
});
});
</script>
<style type="text/css">
</style>
</head>
<body></body>
</html>
I am new to sencha touch and saw all videopodcasts but still don't understand how to "display" a panel from a tabbar (the bar on top!) and how to switch from a panel to another without any slide or something (just display it please!)
There is more on the road like having a preloader and fetch the data from JSON and then display the nested list. But for now I am stuck in this simple scenario...
here is what I have so far...
This is index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Sencha 3</title>
<script type="text/javascript" src="lib/touch/sencha-touch.js"></script>
<link href="lib/touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="phonegap.js"></script>
<script src="app/app.js" type="text/javascript"></script>
<script src="app/views/startcard.js" type="text/javascript"></script>
<script src="app/views/secondcard.js" type="text/javascript"></script>
<script src="app/views/plain.js" type="text/javascript"></script>
<script src="app/views/Viewport.js" type="text/javascript"></script>
</head><body></body>
app.js
Testdemo = new Ext.Application({
name: "TestDemo",
launch: function() {
this.views.viewport = new this.views.Viewport();
this.views.homecard = this.views.viewport.getComponent('startcard');
}
});
Viewport.js
TestDemo.views.Viewport = Ext.extend(Ext.TabPanel, {
fullscreen: true,
initComponent: function() {
Ext.apply(this, {
tabBar: {
dock: 'bottom',
layout: {
pack: 'center'
}
},
items: [
{ xtype: 'startcard'},
{ xtype: 'secondcard'},
]
});
TestDemo.views.Viewport.superclass.initComponent.apply(this, arguments);
}
});
startcard.js
myPrefs = function() {
//here is the problem! How can I display the panel myPrefs??
this.StartCard.setActiveItem('myPrefs', {type:'slide', direction:'down'});
}
refreshHome = function() {
alert("Refresh me!");
}
var somelist = new Ext.Component({
title: 'testline 1',
cls: 'info',
html: 'This is plain Text.<br />Some JSON-Data should be listed here...'
})
TestDemo.views.StartCard = Ext.extend(Ext.Panel, {
title: "TestDemo",
iconCls: "home",
styleHtmlContent: true,
scroll: 'vertical',
initComponent: function() {
Ext.apply(this, {
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
title: 'Some Test App',
items: [
{
iconMask: true,
ui: 'plain',
iconCls: 'settings',
itemId: 'btnHomeMore',
title: 'Do I need a title???',
handler: myPrefs
},
{
xtype: 'spacer'
},
{
iconMask: true,
ui: 'plain',
iconCls: 'refresh',
itemId: 'btnRefreshMe',
title: 'Refresh, i guess',
handler: refreshHome
}
]
}
],
items: [
{
itemId: 'MyStartPage',
html: 'This is just a test'
}
]
});
TestDemo.views.StartCard.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('startcard', TestDemo.views.StartCard);
Ok, it isn't exactly clear what the question is from your description so I will try to help with all your points.
With a TabBar you 'display' a panel by making it the active one. By default the first item is displayed.
In ViewPort.js, you will need to add a property 'text' to the items so that the tab has the proper text.
Ext.apply(this, {
tabBar: {
dock: 'bottom',
layout: {
pack: 'center'
}
},
items: [
{ xtype: 'startcard', text: 'Start Card'},
{ xtype: 'secondcard', text: 'Second Card'},
]
});
However I don't see your 'secondcard' type defined anywhere so it may be throwing an error. You should load up your page in Chrome/Safari and see if it displays any JS errors using the Developer Console. These errors will prevent behaviour of the components from working properly.
Clicking on the button for that tab will now switch to that card using whatever animation you have configured as the 'cardSwitchAnimation' for the TabBar.
I am new to sencha touch so if someone can point me in the right direction that would be great. My problem is that I want to display data from my database. I seem to have everything working correctly when I inspect the elements I see the data but I can't see the data on the screen Here is my code:
getUserList.js
Ext.regModel("User", {
fields: [
"id",
"name",
"username",
"password",
"email",
"phone"
]
});
var myStore = new Ext.data.Store({
model: 'User',
proxy: {
type: 'ajax',
url : '../sencha/php/getUserList.php',
reader: {
type: 'json',
root: 'results'
}
},
autoLoad: true
});
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{id}">',
'<div class="thumb">title="{name}"></div>',
'<span class="x-editable">{name}</span></div>',
'<div style="background-color:#00F" class="thumb-wrap" id="{id}">{id}</div>',
'</tpl>',
'<div class="x-clear"></div>'
);
var panel = new Ext.extend(Ext.Panel,{
id:'images-view',
frame:true,
width:535,
autoHeight:true,
collapsible:true,
layout:'fit',
title:'Simple DataView',
initComponent: function() {
panel.superclass.initComponent.call(this);
},
items: new Ext.DataView({
store: myStore,
tpl: tpl,
autoHeight:true,
multiSelect: true,
overItemCls:'x-view-over',
itemSelector:'div.thumb-wrap',
emptyText: 'No images to display'
})
});
//panel.render(Ext.getBody());
Ext.reg('userPanel', panel);
index.html
<!DOCTYPE html>
User
<script type="text/javascript" src="sencha/sencha-touch.js"></script>
<script type="text/javascript" src="js/getUserList.js"></script>
<link href="sencha/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var topPanel = {
style: 'padding:15px; background-color: #F00',
html: 'color2'
};
new Ext.Application({
launch: function() {
new Ext.Panel({
fullscreen: true,
layout: {
type: 'hbox',
align: 'stretch'
},
items:[{
xtype: 'userPanel'
}],
dockedItems: [topPanel]
});
}
});
</script>
</head>
<body></body>
Thanks for any help you can provide!
I figured it out, I had to add a layout to my xtype in my index.html file