Example #1
0
        protected override bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            bool   result = base.LoadPostData(postDataKey, postCollection);
            string val    = postCollection[this.ConfigID.ConcatWith("_SM")];

            if (val != null && this.SelectionModel.Primary != null)
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.MissingMemberHandling = MissingMemberHandling.Ignore;
                StringReader sr = new StringReader(val);

                if (this.SelectionModel.Primary is RowSelectionModel)
                {
                    SelectedRowCollection ids = (SelectedRowCollection)serializer.Deserialize(sr, typeof(SelectedRowCollection));
                    (this.SelectionModel.Primary as RowSelectionModel).SetSelection(ids);
                }
                else if (this.SelectionModel.Primary is CellSelectionModel)
                {
                    SelectedCellSerializable cell = (SelectedCellSerializable)serializer.Deserialize(sr, typeof(SelectedCellSerializable));

                    if (cell != null)
                    {
                        CellSelectionModel sm = this.SelectionModel.Primary as CellSelectionModel;
                        sm.SelectedCell.RowIndex = cell.RowIndex;
                        sm.SelectedCell.ColIndex = cell.ColIndex;
                        sm.SelectedCell.RecordID = cell.RecordID;
                        sm.SelectedCell.Name     = cell.Name;
                        sm.SelectedCell.Value    = cell.Value;
                    }
                }
            }

            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="postDataKey"></param>
        /// <param name="postCollection"></param>
        /// <returns></returns>
        protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            string val = postCollection[this.HiddenName ?? this.ConfigID];

            if (val != null)
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.MissingMemberHandling = MissingMemberHandling.Ignore;
                StringReader sr = new StringReader(val);

                SelectedCellSerializable cell = (SelectedCellSerializable)serializer.Deserialize(sr, typeof(SelectedCellSerializable));

                if (cell != null)
                {
                    this.SelectedCell.RowIndex = cell.RowIndex;
                    this.SelectedCell.ColIndex = cell.ColIndex;
                    this.SelectedCell.RecordID = cell.RecordID;
                    this.SelectedCell.Name     = cell.Name;
                    this.SelectedCell.Value    = cell.Value;
                }
            }

            return(false);
        }