Skip to main content

INotifyPropertyChanged not working for Dictionary

Comments

7 comments

  • guest

    Actually, I want to display the CalcRequests.Name & CalcRequests.Values into the grid....can I used the event driven model?

    0
  • Dapfor Team

    Hello,
    Reviewing your code, we noticed that you add to the grid only the IDictionary object returned by CalcRequests.Values. But in reality you need to display contents of two objects: CalcRequests and the second one, returned by CalcRequests.Values.
    Your question is very interesting because it can be generalized not only for dictionaries in your case but also for any other objects. Thank you for it. Seen that it will be extremely powerful functionality of our object model, we desided to add a support for composite objects to the next version of the grid.
    Nevertheless, if you do not want to wait for a new version, you can implement the necessary functionality yourself. As you can see, the grid can work with different types of objects - custom classes, dictionaries etc. This is due to the IDataAccessor interface. When you add your objects to the grid they are wrapped by implementations of this interface. Custom objects - by DataObjectAccessor, dictionaries - by DictionaryDataAccessor etc. So you can add your own implementation, which will work with composite objects.

    Best regards,
    The Dapfor Team

    0
  • guest

    Thanks! The composite object will be helpful.
    As I've an existing project that using other commercial grid that support the composite object. It will be great if Dapfor support it ASAP....

    Also, I have the following questions regarding the features:

    1. does the ListDataAccessor / DictioniaryDataAccessor support the notification for the new element (new columns) ?

    here is the example:
    // when initialize:
    grid.Headers[0].Add(new Dapfor.Net.Ui.Column("Name"));
    grid.Headers[0].Add(new Dapfor.Net.Ui.Column("Price"));
    grid.Headers[0].Add(new Dapfor.Net.Ui.Column("Quantity"));
    Hashtable hashTable1= new Hashtable();
    hashTable1.Add("Name", "AAA");
    hashTable1.Add("Price", 10.23);
    hashTable1.Add("Quantity", 645);
    grid.Rows.Add(hashTable1);
    Hashtable hashTable2= new Hashtable();
    hashTable2.Add("Name", "BBB");
    hashTable2.Add("Price", 12.23);
    hashTable2.Add("Quantity", 15);
    grid.Rows.Add(hashTable2);


    //User want to add a new column that the column formula / definition is generated at the run time ( dynamic column).
    grid.Headers[0].Add(new Column("Total Value"));
    hashTable1.Add("Total Value", 14645);
    hashTable2.Add("Total Value", 76381);

    can the DataAccessor (Dictionary / List) know the new element and display the new column at runtime?


    2. any better way to support a conditional formatting ( where the user can change the condition at run time)

    0
  • Dapfor Team

    Hello,
    1. If you add a new column and your dictionary objects contain a key that is a column identifier – there is nothing to implement – values will be displayed in appropriate cells.
    2. Yes, your values are usually of int, double… types. This is your business data and it shouldn’t been formatted when you add it to the grid. Otherwise you can encounter incorrect sorting or grouping. For example if you try to sort dates that are represented differently in US and UK. The grid provides powerful instruments to format these values when they are displayed in cells. You can do it by implementing the IFormat interface. More details you will find here: http://www.dapfor.com/Feature.aspx?id=data_formats. Also in feature versions we want to provide instruments to edit formats directly in columns (for ex, when the user can specify how many digits he wants to see for float values in columns) and serialize there preferences into xml or binary archive.
    Best regards,
    The Dapfor Team

    0
  • guest

    thanks!

    For Q1, even if the dictionary object didn't have that Key when the new column is added, I assume Dapfor can populate the data correctly.

    For Q2, let me give a better example:

    e.g. user want to specify a formatting rule at runtime:

    if col[PRICE] > 30 , BgColor = Green, Fg = Black
    if col[PRICE] < 20 , FgColor = Red, Font = Tahoma, ApplyToRow = True

    you can refer to the example from other vendor product:
    http://documentation.devexpress.com/#XtraReports/CustomDocument5167

    they provide a Formatting editor and allow user to change the formatting rule at run time.

    Will dapfor consider this features as well? If yes, any roadmap?

     

    0
  • Dapfor Team

    Wow! What efforts were made by DevExpress! And all this is just for values rendering in cells! We think that this is a dead end road for following reasons:

    1. It is not clear for developers and is not intuitive. They have to look though tons of documentation to understand how it works. And also there are some problems with code debugging.
    2. It is not safe. Especially conditional strings parsing and casting to appropriate types.
    3. Such grids are too slow with high memory consumption!
    4. The project is not stable at design-time while serialization/deserialization and will take huge amount of lines in InitialComponent() method.
    5. We do not like string expressions like [UnitPrice] >= 30.

    All of the above you can do by handling the Grid.PaintRow event.


    grid.PaintRow += delegate(object sender, PaintRowEventArgs e)
    {
    double price = (double)e.Row["Price"].Value;
    if (price > 30)
    {
    e.Appearance.BackColor = Color.Green;
    e.Appearance.ForeColor = Color.Black;
    }
    else if (price < 20)
    {
    e.Appearance.ForeColor = Color.Red;
    e.Font = "your font";
    }
    };



    No problems with Q1.

     

    0
  • Dapfor Team

    The NetGrid release v.2.4 includes composite object support that significantly reduces and simplifies application code and enables more complete separation of business logic layer from data presentation layer in GUI. Composite objects may have properties returning primitive types and references to other objects. When binding to such objects, the grid can display information from the composite objects and from referenced objects. The grid binds to properties of this objects and doesn't distinguish data source when displaying data. Therefore, there is no more need to create intermediate classes or containers aggregating information of differrent objects for its future display in the grid. Work with composite objects also supports event-driven model enabling the grid to automatically sort, filter group and higlight data received from composite objects.

    http://www.dapfor.com/Feature.aspx?id=composite_objects

    Best regards,

    The Dapfor Team

    0

Please sign in to leave a comment.

Powered by Zendesk