Closed vegarringdal closed 7 years ago
Although the data part of my app is really simple (just show data items) I will have a look when I'm back at work. Recently I've tried to introduce a "redux-ish" behaviour to the app which takes a lot of time (it needs "predictable state"). Not sure when that's finished.
One thing about the function names. I think they are a little confusing. Especially the addNew
/addToArray
pair. How about this (same order as your list)?
unshift(data: any)
- no optional data, appends to top (like array unshift
)resetArray(array)
- see refresh
push(data: any)
- array terminology againremove(row?: Row | Row[])
- don't take the Row
to seriously, it's only there for clarity - essentially remove the current without any parameters, remove a single row when row
is not an array, remove the row array if row
is an arrayrefresh(array?: any[])
- I just like "refresh" better but that may be personal taste 😃 - if an array is given, it would behave like the resetArray
addBlankRow()
- I think this function should have a specific name and it deserves itNot sure about unshift
and push
but I'll keep it there for the sake of discussion. 😃
In general I'm not sure if some of these are too "coupled" to the grid (as opposed to the data). For instance addNew()
without any arguments manipulates the grid directly, right? If so, it's not manipulating the data which IMO a datasource should be all about.
removeCurrent()
is a similar case. I'd probably split that into a getSelectedRow()
/removeRow()
pair.
thx, like it, Ill have a new look at these when I start adding more. Added the addRows atm, didnt see this before now, and added it to the demo, just to see how it behaves/ see bugs better. No problem changing name, only you that use it so we can break it a lot 😂
addNew would add a empty row in array binded to grid... Im not doing slice when you set array. (maybe I should)
A lot we can do to improve how default datasource works.
These are now added, removed my addRows
unshift(data: any)
refresh(array?: any[])
addBlankRow()
push(data: any)
remove(rows?: rows[])
does not do anythingAll of these need some tuning, a lot more testing, refresh etc uses orderby and grouping, but overlook filter atm, same with push and addBankRow/unshift
Note to my self
added the remove
Need to add some more defaults here @Thanood, if you have any suggestions that will make it easier for your app, then please add comments
Atm I have setArray, this resets all sorting/grouping etc
Was thinking about adding these: