Example #1
0
        public void CallBackMethod(string eventArgument)
        {
            // 16.10.2004, jorn - Added UpdateRowsClick, added support for autosave.
            if (string.IsNullOrEmpty(eventArgument))
                return;
            if (EnableCallBack)
            {
                eventArgument = HttpUtility.UrlDecode(eventArgument, Encoding.Default);
                eventArgument = eventArgument.Replace("%27", "'");
            }
            string[] eventArgs = eventArgument.Split('!');
            // ColumnId of the event
            string postBackEvent = eventArgs[0];

            // If RaisePostBackEvent is raised programatically.
            m_EventRanInit = true;

            if (GridPostBack != null)
            {
                GridPostBackEventArgs ea = new GridPostBackEventArgs { EventName = postBackEvent };
                ea.SetEventArguments(eventArgs);
                GridPostBack(this, ea);
            }
            if (PagerSettings.PagerType == PagerType.Slider || PagerSettings.PagerType == PagerType.RangedSlider)
                PagerSettings.updateSliderValues();

            if (Trace.IsTracing)
                Trace.Trace("{0} : Start CallBackMethod() Event: {1} Args length:{2}", ID, postBackEvent,
                            eventArgs.Length);
            if (Debug)
                m_DebugString.AppendFormat("<b>{0}: CallBackMethod event '{1}' has value array '{2}'</b><br/>", ID,
                                           postBackEvent, eventArgument);
        }
Example #2
0
        /// <summary>
        /// When implemented by a class, enables a server control to process an event raised when a form is posted to the server.
        /// </summary>
        /// <param name="eventArgument">A <see cref="T:System.String"></see> that represents an optional event argument to be passed to the event handler.</param>
        /// <remarks>
        /// Supported eventarguments are:
        /// 
        /// UpdateRowsClick,  UpdateRowClick, RecordClick, RecordCopyClick, ExcelExportClick, CollapseGridClick, CollapseGridClick, ColumnHeaderClick
        /// SlaveGridClick, RecordUpdateClick, RecordCancelClick, NewRecordClick, PagerClick, RecordDeleteClick, ElementPostBack. For further examples how to use these please
        /// see WebGrid starter kit.
        /// </remarks>
        public void RaisePostBackEvent(string eventArgument)
        {
            // 16.10.2004, jorn - Added UpdateRowsClick, added support for autosave.
            if (string.IsNullOrEmpty(eventArgument))
                return;
            if (EnableCallBack)
            {
                eventArgument = HttpUtility.UrlDecode(eventArgument, Encoding.Default);
                eventArgument = eventArgument.Replace("%27", "'");
            }
            string[] eventArgs = eventArgument.Split('!');
            // ColumnId of the event
            string postBackEvent = eventArgs[0];

            // If RaisePostBackEvent is raised programatically.
            m_EventRanInit = true;

            if (GridPostBack != null)
            {
                GridPostBackEventArgs ea = new GridPostBackEventArgs {EventName = postBackEvent};
                ea.SetEventArguments(eventArgs);
                GridPostBack(this, ea);
            }
            if (Trace.IsTracing)
                Trace.Trace("{0} : Start CreatePostBackvent() Event: {1} Args length:{2}", ID, postBackEvent,
                            eventArgs.Length);
            if (Debug)
                m_DebugString.AppendFormat("<b>{0}: Post back-event '{1}' has value array '{2}'</b><br/>", ID,
                                           postBackEvent, eventArgument);
            postBackEvent = postBackEvent.ToLowerInvariant();

            switch (postBackEvent)
            {
                case "refresh":
                    {
                        if (PagerSettings.PagerType == PagerType.Slider || PagerSettings.PagerType == PagerType.RangedSlider)
                            PagerSettings.updateSliderValues();
                        break;
                    }
                case "columnpushup":
                    {
                        PushRowUp(eventArgs);
                        break;
                    }
                case "columnpushdown":
                    {
                        PushRowDown(eventArgs);
                        break;
                    }
                case "updaterowsclick":
                    {
                        m_IsRecordUpdateRows = true;
                        m_GetColumnsPostBackData = true;
                        break;
                    }

                case "updaterowclick":
                    {
                        if (InternalId == null)
                        {
                            InternalId = eventArgs[1];
                            m_ResetEditIndex = true;
                        }
                        m_UpdateRow = eventArgs;
                        m_GetColumnsPostBackData = true;
                        break;
                    }
                case "recordclick":
                    {
                        RecordClick(eventArgs);
                        break;
                    }
                case "groupclick":
                    {
                        GroupClick(eventArgs);
                        break;
                    }
                case "recordcopyclick":
                    {
                        m_IsCopyClick = true;
                        CopyRecordClick(eventArgs);
                        break;
                    }
                case "excelexportclick":
                    {

                        ExcelExportClick();
                        break;
                    }
                case "collapsegridclick":
                    {
                        CollapseGridClick();
                        break;
                    }
                case "columnheaderclick":
                    {
                        ColumnHeaderClick(eventArgs);
                        break;
                    }
                case "slavegridclick":
                    {
                        SlaveGridClick(eventArgs);
                        break;
                    }
                case "recordupdateclick":
                    {
                        m_GetColumnsPostBackData = true;
                        RecordUpdateClickEvent(eventArgs);
                        break;
                    }
                case "recordcancelclick":
                    {
                        RecordCancelClickEvent(eventArgs);
                        break;
                    }
                case "newrecordclick":
                    {
                        NewRecordClickEvent();
                        break;
                    }
                case "pagerclick":
                    {
                        PagerClickEvent(eventArgs);
                        break;
                    }
                case "recorddeleteclick":
                    {
                        RecordDeleteClickEvent(eventArgs);
                        ReLoadData = true;
                        break;
                    }
                case "elementpostback":
                    {
                        m_GetColumnsPostBackData = true;
                        ColumnPostBackEvent(eventArgs);
                        break;
                    }
                case "searchclick":
                    {
                        UpdateGridSearch();
                        break;
                    }
            }

            if (Trace.IsTracing)
                Trace.Trace("{0} : Finish CreatePostBackvent()", ClientID);
        }