-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version 2.x refactoring to support Multiple Grid #19
Comments
Migration Changes Guide from version |
@jmzagorski |
For number 7 i think you wanted to keep the editor and filter configuration separated in the That would mean leave the editor on the params or move them to an editor specific property (in reference to number 13) |
@jmzagorski The end goal is to get some Types (and intellisense when the coding editor supports it, like VScode). I wanted to wait until Filters and Editors were stable enough, I think they are now, and for version I don't think that leaving all of the Editors stuff in |
Here are a few other options I could think of to brainstorm about:
|
I was thinking about your number 1. too, the downside is that it makes the property calls longer. Unless you want to merge Editor/Filter properties and only separate the ones that you want? But that might be confusing for collection stuff This kinda mean that Editor and Filter will have the exact same collection behavior. Is that always wanted? options: {
collection: [
{ value: '', label: '' },
{ value: true, label: 'true' },
{ value: false, label: 'false' },
{ value: undefined, label: 'undefined' }
],
collectionFilterBy: {
property: 'effortDriven',
operator: OperatorType.notEqual,
value: undefined
},
collectionSortBy: {
property: 'effortDriven', // will sort by translated value since "enableTranslateLabel" is true
sortDesc: false, // defaults to "false" when not provided
fieldType: FieldType.boolean // defaults to FieldType.string when not provided
},
type: FilterType.multipleSelect
} Your number 2. I'm not sure to follow you on how to fake |
I think combing it might be troublesome, but that is just a guess. For example, in my app I dynamically filter the onCellClick: ({ columnDef, dataContext }) => {
columnDef.params.collectionFilterBy = {
property: 'jobTitleId',
value: dataContext.ownerJobTitleIds,
operator: OperatorType.contains
};
}, So if this was changed every time a cell was clicked, will this affect the header filter? I know the header filter is rendered early on so it might not affect it unless the header filter updates while the user is using the grid. As for number 2, yes it is sort of "hacky" i guess. The only thing it does is makes your public API cleaner and not tied to slickgrid anymore. Here is a brief example of how it could work without changing the underlying column definitions: this.grid = new Slick.Grid(`#${this.gridId}`,
this.dataview,
// if we made the Editor class property name "slickEditor"
this._columnDefinitions.map(c => ({ ...c, editor: c.editor.slickEditor })),
this.gridOptions); |
hmm maybe with the spread operator it doesn't look too bad. What is |
Today {
editor: Editors.date,
field: 'due',
filter: {
type: FilterType.compoundDate
},
filterable: true,
formatter: Formatters.dateIso,
id: 'due',
name: 'Due',
sortable: true,
type: FieldType.dateIso
} Brainstorm {
editor: {
slickEditor: Editors.date,
// ... other editor options here
},
field: 'due',
filter: {
type: FilterType.compoundDate
},
filterable: true,
formatter: Formatters.dateIso,
id: 'due',
name: 'Due',
sortable: true,
type: FieldType.dateIso
} |
but where is the part to swap the property in a temp variable? Isn't your this.grid = new Slick.Grid(`#${this.gridId}`,
this.dataview,
// if we made the Editor class property name "slickEditor"
this._columnDefinitions = this._columnDefinitions.map(c => ({ ...c, editor: { }, editorOptions: c.editor })),
this.gridOptions); BTW, I'd like to have the brainstorm done by the end of this week and implement it in the weekend and then in my Angular repo on Monday. I need multiple grids in my project, like now lol |
oh yeah i forgot that part, and I forgot about the editorFactory property on If you were to use editorOptions the reassignment would look like this: this.grid = new Slick.Grid(`#${this.gridId}`,
this.dataview,
// if we made the Editor class property name "slickEditor"
this._columnDefinitions = this._columnDefinitions.map(c => ({ ...c, editor: c.editor.slickEditor, editorOptions: { ...c.editor } })),
this.gridOptions); If you were to use editor factory it would look like this: -for (const c of this._columnDefinitions) {
- if (c.editor) {
- c.editor = Factory.of(c.editor).get(this.container);
- }
-}
+ this.gridOptions.editorFactory {
+ getEditor: column => Factory.of(this.columnDefinitons.find(c => c.id === +column.id).editor.slickEditor).get(this.container)
+}
this.grid = new Slick.Grid(`#${this.gridId}`,
this.dataview,
// if we made the Editor class property name "slickEditor"
+ this._columnDefinitions = this._columnDefinitions.map(c => ({ ...c, editor: null, editorOptions: { ...c.editor } })),
this.gridOptions); |
When I said Editor Factory, I really meant SlickGrid internal factory which is the column The Which one do you think would be the best option to go with? |
If the {
// today we do
- editor: Editors.date
// but if you wanted to use editor as an object instead for the actual editor class & options
+ editor: {
+ slickEditor: Editors.date,
+ collection: this.editorCollection
// ... other editor options here
},
- params: {
- collection: this.editorCollection
- }
} Not sure if that helps any. I don't have a preference as it stands now.
I wouldn't worry about that if you use the destruction operator. The destruction would make it |
Dohhhh I feel like Omer Simpson now... I didn't realized that we do use the in that case, from your previous post. I think I would go with option number 1 this.grid = new Slick.Grid(`#${this.gridId}`,
this.dataview,
// if we made the Editor class property name "slickEditor"
this._columnDefinitions = this._columnDefinitions.map(c => ({ ...c, editor: c.editor.slickEditor, editorOptions: { ...c.editor } })),
this.gridOptions); |
@jmzagorski |
Makes sense yes. What does your html view on your left-side menu look like? You might be able to catch the event in your view if there is a parent element to your grid without using the EA. |
Ah the example that was written is with my current App, however it's almost identical to our demo with left-side menu, the only difference is that the left-side menu is collapsible. I can re-code our demo to look similar and add the collapsible. The idea is that the left-side menu and the right-side are containers, they don't know what goes in, neither do they have a relationship of Parent/Child, they are independent. See the print screen below, the "x" is clickable which will collapse and only show the icons and not the text. When that "x" is clicked, it doesn't fire an DOM resize events, I think it's due to the fact that I only use a CSS property change and not an actual element resize... all that to say, I had to go with a Global Event Emitter (which in the Aurelia is an Event Aggregator) |
@jmzagorski this._columnDefinitions = this._columnDefinitions.map((c: Column | any) => ({ ...c, editor: this.findEditor((c.editor && c.editor.type), c), internalColumnEditor: { ...c.editor } })), Some notes
The commit for all of that in the Angular-Slickgrid repo can be seen here and I will release a beta version in that repo in the coming days |
I am pretty sure
Not sure what you mean by this. Are you newing up the editor class yourself? |
@jmzagorski The {
id: 'description', name: 'Description', field: 'description', filterable: true, sortable: true, minWidth: 80,
type: FieldType.string,
filter: {
type: FilterType.custom,
customFilter: new CustomInputFilter() // create a new instance to make each Filter independent from each other
}
}, while a Custom Editor looks like this, the only difference is that we can't {
id: 'title2', name: 'Title Custom', field: 'title',
sortable: true, minWidth: 70
type: FieldType.string,
editor: {
type: EditorType.custom,
customEditor: CustomInputEditor
},
} and here's a regular Editor with the new complex {
id: 'prerequisites', name: 'Prerequisites', field: 'prerequisites',
sortable: true, minWidth: 100
type: FieldType.string,
editor: {
type: EditorType.multipleSelect,
collection: Array.from(Array(12).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` })),
collectionSortBy: {
property: 'label',
sortDesc: true
},
collectionFilterBy: {
property: 'label',
value: 'Task 2'
}
}
} |
I update the migration guide for the |
okay I see what you mean with the What about the |
@jmzagorski |
@jmzagorski Anyhow, here's the last info on the project
Error: Module name "flatpickr/dist/l10n/fr.js" has not been loaded yet for context: _ the error comes from this line. Was the error there before? It's possible, but somehow this require doesn't work with loading the locale with There's only 1 major thing missing and it's to update the Migration Guide with the new changes you've put in for Editors/Filters. The rest should be covered. Of course we will have to update all the Wikis but that can be progressive. EDIT Let me know when you upgrade your work version, I would like to know if it all works after following the Migration Guide. I am planning to release the official version in a week or 2, if it all goes well. And as I mentioned in the release, it's in Beta, so if we need to change something, it is still possible to do so. Thanks for all your help 💯 |
Great job! As for the flatpickr error I never ran into it, but I only use English (however my app will eventually have to be translated into many different languages.) Do you want me to work on the migration guide for the editor/filter changes I committed? |
@jmzagorski |
I will work on that. My plan this week is to work on the migration documentation, fix all the unit tests in my app to make sure everything works (my app was also in the process of going from V1 (Kendoui grid) to V2 (your grid)). Then I will close out our long documentation issue and integrate AureliaSlickgrid V2-Beta to see if anything works differently than expected. |
Sweet that is a nice plan :) oh and don't delete the |
@jmzagorski I don't have an older version anymore, so I can't really test this. Or perhaps, I could use the Github demo and use previous Aurelia-Slickgrid version but I would have to remodify the example 4 again. |
Good thing I am behind on my pulls. My master is 9 commits behind, the last commit I have is |
Found the issue: the clear filters calls UPDATE: |
oh ok good thing I asked then, did you just find the issue or do you know how to fix it? Actually, I think I know what to do, I should simply clear the |
Just found it. Not sure how much work I will be able to do tonight. |
ah it's ok, there's no rush. I wanted to push a Beta and it is done. I just encounter coupe of small issues, like that one, while testing other things in my work project. We can now use the |
@jmzagorski My question to you is the following, can we pass a custom Basically a custom validator would look like this const myCustomTitleValidator = (value) => {
if (value == null || value === undefined || !value.length) {
return { valid: false, msg: 'This is a required field' };
} else {
return { valid: true, msg: null };
}
}; and pass it to the definitions this.columnDefinitions = [
{ id: 'title', field: 'title', editor: { model: Editors.longText }, validator: myCustomTitleValidator }
]; I didn't try it since I'm not in Aurelia, but I wish it works. Can you confirm? EDIT |
@jmzagorski Hmm actually, our formatters are not classes, not sure if that would implicate a lot more changes on the end user side of it? |
Right, formatters are more challenging. Two methods I can think of off the top of my head right now:
@inject(i18n)
export class MyFormatter {
constructor(i8n i8n, row, cell, value, columnDef, dataContext) {
}
} I am sure there are better ways and I can think of some as I am going through my code. |
@jmzagorski Any suggestions on how to fix this? I think it should be this this._columnFilters[columnDef.id] = {
columnId: columnDef.id,
columnDef,
searchTerms,
- operator: (columnDef && columnDef.filter && columnDef.filter.operator) ? columnDef.filter.operator : null
+ operator: (columnDef && columnDef.filter && columnDef.filter.model.operator) ? columnDef.filter.model.operator : null
}; actually that seems to cause other problems hmmm |
@jmzagorski |
@jmzagorski operator = filter.operator || (columnDef && columnDef.filter && columnDef.filter.operator); is that ok? or the inverse, I don't know which one should be checked first? operator = (columnDef && columnDef.filter && columnDef.filter.operator) || filter.operator; |
that should be fine unless |
Yeah I see that in the in So the final result is this addFilterTemplateToHeaderRow(args: { column: Column; grid: any; node: any }) {
const columnDef = args.column;
const columnId = columnDef.id || '';
if (columnDef && columnId !== 'selector' && columnDef.filterable) {
let searchTerms: SearchTerm[] | undefined;
let operator: OperatorString | OperatorType;
+ const filter: Filter | undefined = this.filterFactory.createFilter(args.column.filter);
+ operator = (columnDef && columnDef.filter && columnDef.filter.operator) || (filter && filter.operator) || undefined;
if (this._columnFilters[columnDef.id]) {
searchTerms = this._columnFilters[columnDef.id].searchTerms || undefined;
operator = this._columnFilters[columnDef.id].operator || undefined;
} else if (columnDef.filter) {
// when hiding/showing (with Column Picker or Grid Menu), it will try to re-create yet again the filters (since SlickGrid does a re-render)
// because of that we need to first get searchTerm(s) from the columnFilters (that is what the user last entered)
searchTerms = columnDef.filter.searchTerms || undefined;
- this.updateColumnFilters(searchTerms, columnDef);
- operator = columnDef.filter.operator || undefined;
+ this.updateColumnFilters(searchTerms, columnDef, operator);
} I finally took the time to port it over to my Angular repo, which is how I find this issue. |
do you need the last |
well I just saw that the |
if your first or second expression is false then it will be undefined without the 3rd expression because there will be no 3rd expression to evaluate. For example if |
oh right I've been working on this for 2 late nights recently and don't see these obvious things anymore lol |
lol I have been there too so I know what you are talking about. |
@jmzagorski |
thanks for updating the migration guide. It looks like the changes I did are in there as well. Sorry I have not been able to do anything. We are missing a few developers so I have to do some extra work over the past week and a half. |
Here's a list of what cannot be done currently in version
1.x
until a new major release comes out2.x
which mean breaking changesgridOptions
(closed by PR fix(eventService): use grid.getOptions for gridDefinition #51)aurelia-slickgrid
ViewModel use aninit()
which usually ask forinit(grid, gridOptions, dataView)
but once we get the grid object, we actually have access to thegridOptions
, so we can simplify this a lot (closed by PR refactor(services): remove gridOptions and columnDefinitions #55).onBackendEventApi
was re-implemented and replaced bybackendServiceApi
(commit)a. to be discussed, having EA globally might help in some cases, in my current project I have a left side menu that when triggered needs to resize the grid (autoResize doesn't work in that case) and I don't think it would be possible without an EA.asg
for Aurelia Events andsg
for SlickGrid/DataView Events & renameeventPrefix
toslickgridEventPrefix
(commit)searchTerms
array instead of doing multiple logic to deal withsearchTerm
(singular) andsearchTerms
array (commit).selectOptions
in all Filters (commit)Column
property and possibly remove thefilter
Column property.FormElementType
from Filters, it should only useFilterType
(commit)FormElementType
is actually not used anywhere else I think, so might be better to delete it completelyonFilterChanged
Event and function should not be named the same, it is rather confusing when troubleshooting, maybe change function toprocessFilterChanged
(commit)exportWithFormatter
from GridOptions.interface since it is now part ofexportOptions
(commit)hideX
andshowX
flags, they should all behideX
since that is the default name in the external plugins (commit)GridExtraService
to simplyGridService
(commit)collection
) are available only from the genericparams
property which removes the benefit of intellisense and type check. This goes with number 7.initOptions
from theBackendService
, that was replaced byinit
some time ago (commit)GridExtraUtil
contain only 1 function, it would be better to move it into the renamedGridService
and deleteGridExtraUtil
completely (commit)i18n
as a Grid Options instead of a genericparams
grid option and fix a column picker issue (commit)column.interface
signature ofonCellClick
andonCellChange
to expose event as first argument to keep consistent with SlickGrid, see issue [Bug]: adding onCellClick on editor column removes autoEdit , doesn't remove selectEditor #60client-cli
and GitHubdemo
samplesThis list will be taken into consideration in the version
2.x
which will be a Major and breaking version.Simply keeping this for reference as of now.
Also, don't expect a version
2.x
any time soon.This will be addressed only when we decided that all features that we want are in place and we want to get rid of all properties and naming that weren't of good use in
1.x
.Migration Guide will be available here
The text was updated successfully, but these errors were encountered: