Thursday, May 26, 2016

Disable previous dates in devexpress mvc DateEdit


<script type="text/javascript">
    function UpdateInfo() {

        var daysTotal = EFFECTIVE_DATE_TO.GetRangeDayCount();
    }

</script>

    @Html.DevExpress().DateEdit(
    settings =>
     {
      settings.Name = "EFFECTIVE_DATE_TO";
      settings.Properties.ClientInstanceName = "EFFECTIVE_DATE_TO";
      settings.Properties.EditFormat = EditFormat.Custom;
      settings.Properties.EditFormatString = "MM/dd/yyyy";
      settings.Properties.ClientSideEvents.DateChanged = "UpdateInfo";
      settings.Properties.DateRangeSettings.StartDateEditID = "EFFECTIVE_DATE_FROM";
      settings.Properties.ValidationSettings.SetFocusOnError = true;
      settings.Properties.ValidationSettings.Display = Display.Dynamic;
      settings.Properties.ValidationSettings.EnableCustomValidation = true;
     }
    ).Bind(Model.EFFECTIVE_DATE_TO).GetHtml()
                                 

Convert String to XML


     String RECORDSXML= "Some Xml text";
      XmlDocument xdoc = new XmlDocument();

      if (RECORDSXML != null)
      {
          xdoc.LoadXml(Server.HtmlDecode(RECORDSXML));
      }

Gridview Settings in Controller for devexpress mvc


private GridViewSettings GetGridViewSettings()
        {
           
            var settings = new GridViewSettings();

            settings.Name = "gvCountry";
            settings.KeyFieldName = "ID";
            settings.CallbackRouteValues = new { Controller = "Master", Action = "CountryPartial" };

            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            settings.SettingsPager.PageSize = 10;
            settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
            settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
            settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

            settings.Settings.ShowFilterRow = true;
            settings.Settings.ShowGroupPanel = false;
            settings.Settings.ShowFilterBar = GridViewStatusBarMode.Visible;
            settings.SettingsSearchPanel.Visible = false;
            settings.SettingsBehavior.ConfirmDelete = true;
            settings.Settings.ShowStatusBar = GridViewStatusBarMode.Hidden;

            settings.Settings.ShowFooter = false;
            settings.Styles.AlternatingRow.Enabled = DevExpress.Utils.DefaultBoolean.True;
            settings.Enabled = true;

            settings.CommandColumn.Visible = true;
            settings.SettingsBehavior.AllowSelectByRowClick = true;
         
                settings.CommandColumn.ShowNewButtonInHeader = true;
         
                settings.CommandColumn.ShowDeleteButton = true;
           
                settings.SettingsEditing.BatchEditSettings.StartEditAction = GridViewBatchStartEditAction.Click;
                settings.SettingsEditing.BatchUpdateRouteValues = new { Controller = "Master", Action = "BatchUpdateCountry" }; //batch
                settings.SettingsEditing.Mode = GridViewEditingMode.Batch; //batch
                settings.SettingsEditing.BatchEditSettings.EditMode = GridViewBatchEditMode.Row;

            settings.Columns.Add(columnsetting =&gt;
            {
                columnsetting.FieldName = "COUNTRY_CODE";
                columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(20);
            });

            settings.Columns.Add(columnsetting =&gt;
            {
                columnsetting.FieldName = "COUNTRY_DESCRIPTION";
                columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(40);
            });

            settings.Columns.Add(columnsetting =&gt;
            {
                columnsetting.FieldName = "NATIONALITY";
                columnsetting.Width = System.Web.UI.WebControls.Unit.Percentage(20);
            });

            settings.Columns.Add(column =&gt;
            {
                column.Caption = "State";
                column.FieldName = "COUNTRY_CODE";
                column.Width = System.Web.UI.WebControls.Unit.Percentage(10);
                column.ColumnType = MVCxGridViewColumnType.HyperLink;
                HyperLinkProperties properties = column.PropertiesEdit as HyperLinkProperties;

                properties.Text = "State";
                properties.NavigateUrlFormatString = Url.Content("~/Master/State?CountryCode={0}");
                column.EditFormSettings.Visible = DefaultBoolean.False;

                column.Settings.AllowDragDrop = DefaultBoolean.False;
                column.Settings.AllowSort = DefaultBoolean.False;
                column.Settings.AllowAutoFilter = DefaultBoolean.False;
            });

            settings.ClientSideEvents.BeginCallback = "gridView_BeginCallback";
            settings.ClientSideEvents.EndCallback = "gridView_EndCallback";

            settings.CustomJSProperties = (s, e) =&gt;
            {
                string records = "<records>";
                var clientData = new Dictionary<int object="">();

                MVCxGridView grid = s as MVCxGridView;
                for (int i = 0; i &lt; grid.VisibleRowCount; i++)
                {
                    records += "<record grid.getrowvalues="" i="" id="\" name="\">";
                }

                records += "</record></int></records>";

                if (access.CanUpdate == false)
                {
                    for (int j = 0; j &lt; grid.DataColumns.Count; j++)
                    {
                        clientData.Add(j, grid.DataColumns[j].FieldName);
                    }
                }
                else
                {
                    clientData.Add(0, "COUNTRY_CODE");
                }

                e.Properties["cpRecords"] = Server.HtmlEncode(records);
                e.Properties["cp_cellsToDisable"] = clientData;
               
            };

            settings.CellEditorInitialize = (s, e) =&gt;
            {
                ASPxEdit editor = (ASPxEdit)e.Editor;
                editor.ValidationSettings.Display = Display.Dynamic;
            };
            settings.ClientSideEvents.BatchEditStartEditing = "gridView_BatchEditStartEditing";
            settings.ClientSideEvents.BatchEditEndEditing = "gridView_BatchEditEndEditing";
            settings.ClientSideEvents.BatchEditRowValidating = "gridView_BatchEditRowValidating";
         

            return settings;
        }

Search

Custom Search
Protected by Copyscape Plagiarism Software