Skip to content

Instantly share code, notes, and snippets.

@hbulens
Last active June 8, 2020 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbulens/ec88686ac2bcb607e87122180445b5fc to your computer and use it in GitHub Desktop.
Save hbulens/ec88686ac2bcb607e87122180445b5fc to your computer and use it in GitHub Desktop.
declare var Ext: any;
const myGrid = Ext.create<MyApp.grids.Users>("SchedulerApp.view.UserGrid");
const currentSelection = myGrid.getSelectionModel().getSelection();
// currentSelection is a type of Ext.selection.Model
// myapp.view.users.ts
Ext.define<MyApp.grids.Users>("MyApp.view.Users", {
extend: "Ext.grid.Panel",
selModel: {
mode: "MULTI"
},
columns: [
Ext.create<any>("MyApp.columns.shared.Name", { filter: { type: "owner" } })
]
}
// myapp.grids.d.ts
declare module MyApp.grids {
export class Users extends Ext.grid.Panel {
}
}
// ext.grid.d.ts
declare module Ext.grid {
export interface Panel extends Ext.Component {
getSelectionModel?(): Ext.selection.Model;
on?(eventName: string, callback: any): void;
setDisabled?(val: boolean): void;
getStore?(): Ext.data.Store;
}
}
declare module Ext {
export interface Component {
extend?: string,
selModel?: Ext.selection.Model,
columns?: any[]
}
}
declare module Ext {
export function create<T>(className: string, config?: T): T;
export function define<T>(className: string, config: T);
}
Ext.define("MyApp.view.CustomersGrid", {
extend: "Ext.grid.Panel",
selModel: {
selType: "rowmodel",
mode: "SINGLE"
},
columns: [{
text: 'Name',
flex: 1,
dataIndex: 'name'
}, {
text: 'Location',
dataIndex: 'location'
}],
initComponent: function () {
}
}
Ext.define("MyApp.panel.Grid", {
constructor(config) {
this.callParent(arguments);
}
})
declare module MyApp.panel {
export class Grid {
constructor(config: any) {
super();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment