Code Monkey home page Code Monkey logo

Comments (6)

ghiscoding avatar ghiscoding commented on June 1, 2024

I was looking at adding more Types in my other lib (Slickgrid-Universal) and I did while encountering some problems understanding how to fully add Type for the Column, I wanted to pass the user's data Type as Column<T> when you define your column definitions and I asked a question about this on Stack Overflow Problem with using a defined TypeScript Generic Type in an external function using the Type T and this Slickgrid-Universal Example is the one that goes with the question. It might not be exactly what you're describing though but it's in the same context. The intention was to pass the data Type to the Column<T> and it would flow to a few other interfaces like the asyncPostRender on dataContext: T.

However note that Aurelia-Slickgrid doesn't have full Type support for these 2 main interfaces of the core SlickGrid and DataView, they were created as SlickGrid and SlickDataView interfaces but they are optional, I added them long after creating the lib and making the lib fully types would break lot of people's code, so I made them as optional and all of my services still refer to grid: any and dataView: any. The goal is to eventually remove all the core/common code from Aurelia-Slickgrid (and Angular-Slickgrid) and use Slickgrid-Universal common place (which is fully Typed) and when that happen (in few months), I'll do a major/breaking version of Aurelia-Slickgrid add full Typing.

To be fair I haven't used much of the Column<T>, it didn't fully work as I wanted (as discussed in the SO) and I only tested with 1 sample, so if you want to change that portion, we could still do it since SlickGrid & DataView are still optional in Aurelia-Slickgrid and barely (if any) are using Slickgrid-Universal and there's no Type in Salesforce (where I use my other lib) because it's ES6 syntax. I don't think anyone knows about the Column<T> since I didn't advertise it in any demo (apart from Slickgrid-Universal single example).

Again I must say, it's fun to see some people (you) start looking at my code and pinpoint some of my implementation errors hehe 😉

Actually I looked back at my Example and the intellisense does work like I wanted, which is cool and is driven by Column<T> ... WAIT I was wrong, I added item: ReportItem and that is where it gets the Type

interface ReportItem {
  title: string;
  duration: number;
  cost: number;
  percentComplete: number;
  start: Date;
  finish: Date;
  effortDriven: boolean;
}

/** Custom Formatter */
const customEditableInputFormatter = (row: number, cell: number, value: any, columnDef: Column, item: ReportItem) => {
  return item.title;
};

export class Example4 {
  columnDefinitions: Column<ReportItem>[];
  // ...
}

image

from aurelia-slickgrid.

zewa666 avatar zewa666 commented on June 1, 2024

Errors is a hefty word. I would say the use cases merely differ ;). The primary need for typesafety for me is on the field property of the column since this gets mapped to a fetched result when populating data and refactoring string based identifiers is a major PITA. The current Column generic was a fun trap since as you pointed out your cast in asyncRenderer did the job.

I can create a PR and you give it a try and decide whether you like and want to merge.
Anyways though I guess your approach to moving the core to universal is certainly a good one and as it stands for now as described initially I have my workaround with a few custom casts so no problem if it doesnt end up being merged.

Edit:
Yes I did look a couple of times at your codebase and I like the simplicity of it. Tbh it was also one of the deciding factors besides the Aurelia interop for your grid control. It makes sure I can modify things as I like and in best case even contribute some of them back, which certainly will be more once our new projects kicks off. I'm still in the prep/analysis phase so going a bit slower since contributions are merely in my spare time.

from aurelia-slickgrid.

ghiscoding avatar ghiscoding commented on June 1, 2024

I'm totally open to any contributions, since they are so rare I do enjoy them whenever they come. I didn't have good result with Column<T>, so I'm open to anything that could help improve the lib in any ways.

from aurelia-slickgrid.

zewa666 avatar zewa666 commented on June 1, 2024

You'll gonna like and hate what you see in a couple of minutes :)

from aurelia-slickgrid.

zewa666 avatar zewa666 commented on June 1, 2024

here it is. Its draft on purpose, you'll see why when reading it #442

from aurelia-slickgrid.

ghiscoding avatar ghiscoding commented on June 1, 2024

closed by PR #466

from aurelia-slickgrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.