Esempio n. 1
0
        private static void DefaultColumnsSizeCb(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SfDataGrid dataGrid = d as SfDataGrid;

            if (d != null)
            {
                ObservableCollection <KarveGridExt.ColParamSize> cols = GetDefaultColumnsSize(d, e);
                // ok here we can set the columns.
                if (dataGrid != null)
                {
                    foreach (var value in cols)
                    {
                        if (value.ColumnIndex < dataGrid.Columns.Count)
                        {
                            dataGrid.Columns[value.ColumnIndex].Width = value.ColumnWidth;
                        }
                    }
                    // FIXME: usare la base de datos con los colmmans para riversar la serialization in a memory stream.
                    var combinePath = Path.Combine(_gridOptionPath, "GridOptions_" + dataGrid.Name + ".xml");
                    using (var file = File.Open(combinePath, FileMode.Open))
                    {
                        dataGrid.Deserialize(file);
                    }

                    dataGrid.RefreshColumns();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///  This load the parameters
        /// </summary>
        /// <param name="dataGrid">DataGrid to be used</param>
        /// <param name="serializedString">The serialized string to be used</param>

        private static void LoadParameters(SfDataGrid dataGrid, string serializedString)
        {
            DeserializationOptions options = new DeserializationOptions();

            options.DeserializeFiltering = false;
            if (string.IsNullOrEmpty(serializedString))
            {
                return;
            }
            using (MemoryStream ms = new MemoryStream())
            {
                using (StreamWriter writer = new StreamWriter(ms))
                {
                    writer.Write(serializedString);
                    writer.Flush();
                    byte[] byteArray = ms.ToArray();
                    using (MemoryStream reader = new MemoryStream(byteArray))
                    {
                        dataGrid.Deserialize(reader, options);
                    }
                }
            }
        }
Esempio n. 3
0
        public static void CustomDeserialize(this SfDataGrid dataGrid, byte[] disposition, bool deserializeDetailsViewDefinition = false)
        {
            DeserializationOptions options = new DeserializationOptions
            {
                DeserializeColumns = true,
                DeserializeSorting = true
            };

            if (deserializeDetailsViewDefinition)
            {
                options.DeserializeDetailsViewDefinition = true;
            }

            using (MemoryStream ms = new MemoryStream(disposition))
            {
                dataGrid.Deserialize(ms, options);
                dataGrid.AllowDraggingColumns       = false;
                dataGrid.AllowResizingColumns       = false;
                dataGrid.AllowResizingHiddenColumns = false;
                dataGrid.AllowSorting = false;
                dataGrid.AllowEditing = false;
                dataGrid.HideEmptyGridViewDefinition = true;
            }
        }