Exemple #1
0
        protected virtual void ChangeOrderTo()
        {
            if (ParentGrid.DataLink.Active)
            {
                DAE.Client.TableDataSet dataSet = ParentGrid.DataLink.DataSet as DAE.Client.TableDataSet;
                if (dataSet != null)
                {
                    Schema.Order order = FindOrderForColumn();
                    if (order == null)
                    {
                        dataSet.OrderString = "order { " + ColumnName + " asc }";
                    }
                    else
                    {
                        Schema.Order currentOrder       = dataSet.Order;
                        int          currentColumnIndex = currentOrder == null ? -1 : currentOrder.Columns.IndexOf(ColumnName);

                        bool descending = (currentColumnIndex >= 0) && currentOrder.Columns[currentColumnIndex].Ascending;
                        if (!descending ^ order.Columns[ColumnName].Ascending)
                        {
                            order = new Schema.Order(order, true);
                        }

                        dataSet.Order = order;
                    }
                }
            }
        }
Exemple #2
0
        // BEGIN ADAPTED FROM WINDOWS GRID

        protected Schema.Order FindOrderForColumn()
        {
            DAE.Client.TableDataSet dataSet = ParentGrid.DataLink.DataSet as DAE.Client.TableDataSet;
            if (dataSet != null)
            {
                // Returns the order that has the given column as the first column
                if ((dataSet.Order != null) && (dataSet.Order.Columns.Count >= 1) && (dataSet.Order.Columns[0].Column.Name == ColumnName))
                {
                    return(dataSet.Order);
                }

                foreach (Schema.Order order in ParentGrid.DataLink.DataSet.TableVar.Orders)
                {
                    if ((order.Columns.Count >= 1) && (order.Columns[0].Column.Name == ColumnName))
                    {
                        return(order);
                    }
                }

                foreach (Schema.Key key in ParentGrid.DataLink.DataSet.TableVar.Keys)
                {
                    if (!key.IsSparse && (key.Columns.Count >= 1) && (key.Columns[0].Name == ColumnName))
                    {
                        return(new Schema.Order(key));
                    }
                }
            }
            return(null);
        }
Exemple #3
0
 protected virtual void DataChange(DAE.Client.DataLink dataLink, DAE.Client.DataSet dataSet)
 {
     if (dataLink.Active && (dataSet is DAE.Client.TableDataSet))
     {
         DAE.Client.TableDataSet table = (DAE.Client.TableDataSet)dataSet;
         if (_order != table.Order)
         {
             SetOrder(table.Order);
         }
         else
         if (!_searching)
         {
             Reset();
         }
     }
 }
Exemple #4
0
        public override void InternalRenderHeader(HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "gridheaderdatacell");
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Session.GetActionLink(Session.Get(this).Context, _headerID));
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            string title = GetTitle();

            if (title == String.Empty)
            {
                writer.Write(" ");
            }
            else
            {
                writer.Write(HttpUtility.HtmlEncode(Session.RemoveAccellerator(title)));
            }

            DAE.Client.DataLink link = ParentGrid.DataLink;
            if (link.Active)
            {
                DAE.Client.TableDataSet dataSet = ParentGrid.DataLink.DataSet as DAE.Client.TableDataSet;
                if (dataSet != null)
                {
                    Schema.Order order = dataSet.Order;
                    if ((order != null) && (order.Columns.IndexOf(ColumnName) > -1))
                    {
                        writer.Write(" ");
                        if (((Schema.OrderColumn)order.Columns[ColumnName]).Ascending)
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, "images/downarrow.gif");
                        }
                        else
                        {
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, "images/uparrow.gif");
                        }
                        writer.RenderBeginTag(HtmlTextWriterTag.Img);
                        writer.RenderEndTag();
                        writer.Write(" ");
                    }
                }
            }
            writer.RenderEndTag();
        }
        /// <summary> Locates the nearest matching row in one DataSource given another DataSource. </summary>
        /// <param name="target"> The DataSource to target for the search. </param>
        /// <param name="targetColumnNames"> The list of columns to search by. </param>
        /// <param name="source"> A DataSource to pull search values from. </param>
        /// <param name="sourceColumnNames">
        ///		Column names corresponding ATargetColumnNames, which map to fields
        ///		within ASource.
        ///	</param>
        public static void FindNearestRow(DAE.Client.DataSource target, string[] targetColumnNames, DAE.Client.DataSource source, string[] sourceColumnNames)
        {
            //Build the row type
            DAE.Schema.RowType rowType = new DAE.Schema.RowType();
            string             trimmedName;

            foreach (string columnName in targetColumnNames)
            {
                trimmedName = columnName.Trim();
                rowType.Columns.Add(new DAE.Schema.Column(trimmedName, target.DataSet[trimmedName].DataType));
            }

            //Fill in the row values
            bool find = true;

            using (DAE.Runtime.Data.Row row = new DAE.Runtime.Data.Row(target.DataSet.Process.ValueManager, rowType))
            {
                for (int i = 0; i < targetColumnNames.Length; i++)
                {
                    if (!source.DataSet[sourceColumnNames[i].Trim()].HasValue())
                    {
                        find = false;
                        break;
                    }
                    else
                    {
                        row[i] = source.DataSet[sourceColumnNames[i].Trim()].Value;
                    }
                }

                DAE.Client.TableDataSet targetDataSet = target.DataSet as DAE.Client.TableDataSet;
                if (find && (targetDataSet != null))
                {
                    string saveOrder = String.Empty;

                    // If the view order does not match the row to find
                    bool orderMatches = true;
                    for (int index = 0; index < row.DataType.Columns.Count; index++)
                    {
                        if ((index >= targetDataSet.Order.Columns.Count) || !DAE.Schema.Object.NamesEqual(targetDataSet.Order.Columns[index].Column.Name, row.DataType.Columns[index].Name))
                        {
                            orderMatches = false;
                            break;
                        }
                    }

                    if (!orderMatches)
                    {
                        saveOrder = targetDataSet.OrderString;
                        DAE.Schema.Order newOrder = new DAE.Schema.Order();
                        foreach (DAE.Schema.Column column in row.DataType.Columns)
                        {
                            newOrder.Columns.Add(new DAE.Schema.OrderColumn(target.DataSet.TableVar.Columns[column.Name], true));
                        }
                        targetDataSet.Order = newOrder;
                    }
                    try
                    {
                        targetDataSet.FindNearest(row);
                    }
                    finally
                    {
                        if (saveOrder != String.Empty)
                        {
                            targetDataSet.OrderString = saveOrder;
                        }
                    }
                }
            }
        }