Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
51
Changing Result / Cells from xamPivotGrid without generating a new FlatDataSource
posted

Hello, this is Christian from Saarbrücken in Germany.

 

I'm trying to change the xamPivotGrid-cells data after the Cube was generated and displayed, but without any success.

 

This is the structure of the businessobject-list that i am building and using as itemsource for the flatdatasource.

 

public class QMatrix : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private int? _soll = null;
        private int? _ist = null;

        public Mitarbeiter Mitarbeiter { get; set; }
        public Hauptaufgabe Hauptaufgabe { get; set; }
        public DateTime? Termin { get; set; }
        public int ID { get; set; }
        public int? Verantwortlicher { get; set; }
        public int? Soll
        {
            get
            {
                return _soll;
            }
            set
            {
                int? old = _soll;
                try
                {
                    _soll = value;
                    if (old != _soll)
                        OnPropertyChanged("Soll");
                }
                catch (Exception exception)
                {
                    _soll = old;
                    MessageBox.Show(exception.Message, "Property-Fehler", MessageBoxButton.OK);
                }
            }
        }

        public int? Ist
        {
            get
            {
                return _ist;
            }
            set
            {
                int? old = _ist;
                try
                {
                    _ist = value;
                    if (old != _ist)
                        OnPropertyChanged("Ist");
                }
                catch (Exception exception)
                {
                    _ist = old;
                    MessageBox.Show(exception.Message, "Property-Fehler", MessageBoxButton.OK);
                }
            }
        }
        public string Ausbilder { get; set; }

        public QMatrix()
        {
            Mitarbeiter = new Mitarbeiter();
            Hauptaufgabe = new Hauptaufgabe();
        }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
    public class Mitarbeiter
    {
        public int ID { get; set; }
        public string Name { get; set; }

        public Mitarbeiter()
        {
            ID = -1;
            Name = "keiner";
        }
    }
    public class Arbeitsplatz
    {
        public int ID { get; set; }
        public string Name { get; set; }

        public Arbeitsplatz()
        {
            ID = -1;
            Name = "keiner";
        }
    }
    public class Hauptaufgabe
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public Arbeitsplatz Arbeitsplatz{ get; set; }
       
        public Hauptaufgabe()
        {
            ID = -1;
            Name = "keiner";
            Arbeitsplatz = new Arbeitsplatz();
        }
    }

 

private void bildeCube()
        {
            //if (p1loaded == false || p2loaded == false || p3loaded == false)
            //    return;

            try
            {
                Switched = false;

                FlatDataSource fs = new FlatDataSource()
                {
                    ItemsSource = bildeItemsource(),
                    Cube = XmlaDataSource.GenerateInitialCube("QMatrix"),
                    Columns = XmlaDataSource.GenerateInitialItems("[Hauptaufgabe]"),
                    Rows = XmlaDataSource.GenerateInitialItems("[Mitarbeiter]"),
                    Measures = XmlaDataSource.GenerateInitialItems("Ist,Soll"),
                };
                fs.ResultChanged += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(fs_ResultChanged);   

                CubeMetadata cubeMetadata = new CubeMetadata();
                cubeMetadata.DisplayName = "QMatrix-Werte";
                cubeMetadata.DataTypeFullName = typeof(QMatrix).FullName;

                cubeMetadata.DimensionSettings.Add(new DimensionMetadata()
                    {
                        SourcePropertyName = "Ist",
                        DisplayName = "Ist",
                        DisplayFormat = "{0} %"
                    }
                );

                cubeMetadata.DimensionSettings.Add(new DimensionMetadata()
                    {
                        SourcePropertyName = "Soll",
                        DisplayName = "Soll",
                        DisplayFormat = "{0} %"
                    }
                );

                fs.CubesSettings.Add(cubeMetadata);

                HierarchyDescriptor<QMatrix> hauptaufgabenHierarchy = new HierarchyDescriptor<QMatrix>(qmo => qmo.Hauptaufgabe);
                hauptaufgabenHierarchy.AddLevel(qmo => "Alle Arbeitsplätze", "Alle Arbeitsplätze");
                hauptaufgabenHierarchy.AddLevel(qmo => qmo.Hauptaufgabe.Arbeitsplatz.Name, "Arbeitsplatz Bez.");
                hauptaufgabenHierarchy.AddLevel(qmo => "Alle Hauptaufgaben", "Alle Hauptaufgaben");
                hauptaufgabenHierarchy.AddLevel(qmo => qmo.Hauptaufgabe.Name, LEVELNAME_HAUPTAUFGABEN);
                fs.AddHierarchyDescriptor(hauptaufgabenHierarchy);

                HierarchyDescriptor<QMatrix> mitarbeiterHierarchy = new HierarchyDescriptor<QMatrix>(qmo => qmo.Mitarbeiter);
                mitarbeiterHierarchy.AddLevel(qmo => "Alle Mitarbeiter", "Alle Mitarbeiter");
                //mitarbeiterHierarchy.AddLevel(qmo => "", "");
                mitarbeiterHierarchy.AddLevel(qmo => qmo.Mitarbeiter.Name, LEVELNAME_MITARBEITER);
                fs.AddHierarchyDescriptor(mitarbeiterHierarchy);

                //fs.SetMeasureAggregator((Infragistics.Olap.IMeasureViewModel)fs.Measures[0], Infragistics.Olap.MeasureAggregator.Average);
                //fs.SetMeasureAggregator((Infragistics.Olap.IMeasureViewModel)fs.Measures[1], Infragistics.Olap.MeasureAggregator.Average);

                Grid.DataSource = fs;
                DataSelektor.DataSource = fs;           
            }
            catch (Exception exc)
            {
                Switched = true;
                MessageBox.Show(exc.Message, "F E H L E R", MessageBoxButton.OK);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }

 

private List<QMatrix> bildeItemsource()
        {
            List<QMatrix> Werte = new List<QMatrix>();
            QMatrix qmo;
            QMatrixV3.Web.V_QMATRIX_V2 qm;

            for (int i = 0; i < v_QMATRIX_V2DomainDataSource.DataView.Count; i++)
            {
                qm = (QMatrixV3.Web.V_QMATRIX_V2)v_QMATRIX_V2DomainDataSource.DataView[i];
                qmo = new QMatrix();
                qmo.ID = qm.ID;
                qmo.Termin = qm.TERMIN;
                qmo.Verantwortlicher = qm.VERANTWORTLICHER;
                qmo.Soll = qm.Q_SOLL;
                qmo.Ist = qm.Q_IST;
                qmo.Ausbilder = qm.AUSBILDER;

                foreach (QMatrixV3.Web.V_MITARBEITER ma in v_MITARBEITERDomainDataSource.DataView)
                {
                    if (ma.ID == qm.MA_ID)
                    {
                        qmo.Mitarbeiter.ID = ma.ID;
                        qmo.Mitarbeiter.Name = ma.BEZ_MITARBEITER;
                        break;
                    }
                }

                foreach (QMatrixV3.Web.V_HAUPTAUFGABEN ha in v_HAUPTAUFGABENDomainDataSource.DataView)
                {
                    if (ha.ID == qm.H_AUF_ID)
                    {
                        qmo.Hauptaufgabe.ID = ha.ID;
                        qmo.Hauptaufgabe.Name = ha.SEL_STRING;

                        foreach (QMatrixV3.Web.V_ARBEITSPLAETZE ap in v_ARBEITSPLAETZEDomainDataSource.DataView)
                        {
                            if (ap.ID == ha.AP_ID)
                            {
                                qmo.Hauptaufgabe.Arbeitsplatz.ID = ap.ID;
                                qmo.Hauptaufgabe.Arbeitsplatz.Name = ap.BEZ;
                                break;
                            }
                        }

                        break;
                    }
                }


                Werte.Add(qmo);
            }
            return Werte;
        }

 

What I've tried:

  1. I manipulated the values of the mesasures in the itemsource, nothing happend after refreshing the grid.
  2. I changed the olap-cells in the result wit setvalue-function with the wrigth coordinates, no effect.
  3. I tried to put a new olap-cell in the data-property of the pivot-cell at "cell-control-attached"-event ... nothing
  4. The only way that has worked was building a new flatdatasource ... but after that, the grid loses all data like scrollpositions, last activecell, ...

 

Is there any way to manupulate the data and refresh the grid like overriding a method from flatdatasource-class or changing fields from olap-cells ???

 

thx

Chris

Parents Reply Children
No Data