Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
43 views
I have a grid inside a pane. I want to use static headers in the grid and have set that to true. The problem is that the pane scrollbar shows up when the grid scrollbar should show up. I've tried to turn off the pane scrollbar but that did not cause the grid scrollbar to show up. What have I missed? attached is a screen shot. you'll notice the scrollbar on the right is for the pane but I want it for the grid.
Kostadin
Telerik team
 answered on 19 Dec 2012
1 answer
102 views
Hi,
I have  a grid and it's datasource is a datatable. The datatable binds the grid in Pageload . there is another grid in the page and  second grid's databinding is done according to first grid's clicked row. 

The problem is that, second grid never fills.
Florence
Top achievements
Rank 1
 answered on 19 Dec 2012
5 answers
364 views
Hello!

I've spent quite a bit of time researching this, but could not find a solution - so please forgive me if I'm posting a new thread on something that has already been answered.

The functionality I'm looking for is to simply enable/disable a textbox inside of a template column that belongs to a radgrid on that radgrid's client event: OnRowSelected (using a GridClientSelectColumn). I understand how to retrieve actual values via ClientDataKeyNames, but I'm looking to just manipulate the actual textbox control - not retrieve any values. Is there anything you could point me to in order to get me going in the right direction? Any help is greatly appreciated!

(Desired behavior: OnRowSelected --> txtScore.disabled = false;)

Here's my radgrid:
<telerik:RadGrid runat="server" ID="gridEmployees" AllowMultiRowSelection="true"
           OnNeedDataSource="gridEmployees_NeedDataSource" Width="25%" OnDataBinding="gridEmployees_DataBinding"
           AutoGenerateColumns="false" Style="margin: 10px auto 0px auto;" GridLines="None"
           Skin="WebBlue" EnableAJAX="true" ClientSettings-EnablePostBackOnRowClick="false">
           <MasterTableView Name="EmployeeTable" ClientDataKeyNames="EmployeeID, FirstName"
               DataKeyNames="EmployeeID" AllowMultiColumnSorting="False">
               <Columns>
                   <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                   </telerik:GridClientSelectColumn>
                   <telerik:GridBoundColumn SortExpression="FirstName" HeaderText="Employee" AllowFiltering="true"
                       HeaderButtonType="TextButton" DataField="FirstName" UniqueName="FirstName" FilterControlWidth="65px" />
                   <telerik:GridTemplateColumn HeaderText="Score">
                       <ItemStyle Width="100px" />
                       <ItemTemplate>
                           <telerik:RadTextBox ID="txtScore" runat="server" Enabled="false" />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn HeaderText="Notes">
                       <ItemStyle Width="100px" />
                       <ItemTemplate>
                           <telerik:RadTextBox ID="txtNotes" runat="server" Enabled="false" />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn HeaderText="Failed">
                       <ItemStyle Width="20px" />
                       <ItemTemplate>
                           <asp:CheckBox ID="chkFailed" Text="" runat="server" Enabled="false" />
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
               </Columns>
           </MasterTableView>
           <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
               <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />
           </ClientSettings>
       </telerik:RadGrid>
Atlas
Top achievements
Rank 1
 answered on 19 Dec 2012
1 answer
73 views
Hello, all.

I have a perplexing question regarding the RadDock's state properties and JSON.  I'm building an application that has a custom dashboard that will allow the users to add, remove, move, and expand/collapse various .ascx controls; this string will be stored in a SQL database.  As it stands right now, everything works the way it should with no issues.

Since there will be a large amount of users using the application, it was decided that we don't need to physically store every dock state property for all the docks since there are quite a few that can't be changed from a user perspective (docks will never be pinned or resized; the top and left will always be 0, etc.) so we created another table that holds the properties that are changeable (zone, title, etc.).  I changed the SaveDockLayout's handler to save into both tables until I get this new method working and tested.  One table is storing the whole string as per the Telerik demos, the other is taking only the state properties we're saving and inserting/updating/deleting from the database as needed.  So far, this has worked perfectly.

Since we're not storing the whole string as one database field anymore, we're creating a JSON string on the fly in a stored procedure that's loading from the new table.  The values that don't change are hard-coded into the procedure; the others are selected from the database per our criteria.  The results are then output to a JSON-formatted string and then looped through and split as per the code examples.  Docks loaded this way have all the states from the JSON string applied correctly and they render fine.

Here's the hitch.  When the SaveDockLayout event fires when the docks have been loaded with the generated string instead of the stored one, the table that's storing the whole dock state is updating the properties just fine, yet the part of the subroutine that's breaking apart the states doesn't seem to recognize that anything has changed.  For example, if I move a dock from zone 1 to zone 3, the whole dock state is updated correctly in the old table, yet the property going into the new table will still show zone 1.  The same results occur if the title is changed, if the dock is expanded or closed, etc.

So my question is, is there a fundamental difference between storing the whole state string vs. generating one?  I've done a side-by-side comparison of the JSON output of my generated string to the text of the stored string and there's no noticeable difference.  Both strings are created as NVARCHAR(MAX).  All the properties are paired correctly and in the same order.  Each dock is surrounded by opening and closing braces, the docks are separated by a pipe delimiter, each name/value pair has quotes around each part with a colon in between the name and value, plus there's a comma separating each pair.  Is there something else I'm missing that would cause the properties to be updated correctly for one procedure but not the other?
Slav
Telerik team
 answered on 19 Dec 2012
3 answers
112 views
hi,
i've a problem with the javascript function. when start the second if the compilator see me this error:
Run-time error of Microsoft JScript: Object does not support this property or method 'set_text' on this code

why?

function CallNotification() {
    var PwdAttuale = '<%=ViewState("Passwordnow")%>';
    var notification = document.getElementById("<%= RadNotification1.ClientID %>");
    var txtpwdnow = document.getElementById("<%= txtpwdnow.ClientID %>");
    var txtpwdnew = document.getElementById("<%= txtpwdnew.ClientID %>");
    var txtpwdnewconf = document.getElementById("<%= Txtpwdnewconf.ClientID %>");
    if (txtpwdnow.value != PwdAttuale) {
        var messaggio = "Password attuale errata.";
        notification.set_text(messaggio);
        notification.show();
        return false;
    }
    if (txtpwdnew.value != txtpwdnewconf.value) {
         var messaggio = "Password di conferma errata.";
         notification.set_text(messaggio);
         notification.show();
         return false;
     }
 }
Marin Bratanov
Telerik team
 answered on 19 Dec 2012
3 answers
213 views
I have a main window which call the rad window and when the rad window is closed, it should call main window's call back function which is registered for add_close in the main window.Here is the code snippet
(MainWindow)
function
showNewWindow {
                // open radwindow to get new window
                var url = "/Edit.aspx";
                var oWnd = getRadWindow().BrowserWindow.GetRadWindowManager().open(url, "AddNewEditWindow");
                // subscribe to the close event for the window
                oWnd.add_close(getFieldsFromEditWindow);
            }
function getFieldsFromEditWindow()
{
  var WindowName="AddNewEditWindow";
  var targWnd = getRadWindow().BrowserWindow.GetRadWindowManager().getWindowByName(WindowName);
                var editWnd = targWnd.get_contentFrame().contentWindow;
var data_From_EditWindow=editWnd.getDetails();
}
Edit.aspx ( RadWindow)
function getDetails()
{
return "HI";
}

getDetails() function in Edit.aspx is called successfully in chrome and mozilla but in IE it is failing
when the main window is trying to call the getDetails() in call back function "getFieldsFromEditWindow()"
after the rad window is closed.
It is throwing me an error "Object doesn't support property or method 'getDetails'" 
Please help me in fixing this.




Marin Bratanov
Telerik team
 answered on 19 Dec 2012
5 answers
92 views
Hi All,

I am trying to implement within an Image Viewing application which has a RadWindow which opens up on the click of a button.  The idea is that the user can copy information from the image into some fields on the Window.

The main window is a div which contains two other divs - a left "sidebar" panel and a right "viewer" panel
<div id="container">
        <asp:Panel ID="sidebar" runat="server">
           <asp:PlaceHolder ID="phSideBar" runat="server"></asp:PlaceHolder>
        </asp:Panel>
        <asp:Panel ID="viewer" runat="server">
            <asp:PlaceHolder ID="phViewer" runat="server"></asp:PlaceHolder>
        </asp:Panel>
    </div>

The sidebar contains navigation buttons and links and the viewer panel contains a java applet which handles the image viewing.

During page load, the user controls are added to the placeholders.
protected void Page_Load(object sender, EventArgs e)
{    
            System.Web.UI.Control contHardCopyOrdering = (System.Web.UI.Control)LoadControl("vwHardCopy.ascx");
            sidebar.Controls.Add(contHardCopyOrdering);      // Add Order button Control to SideBar  phSideBar
 
            ViewerServerControl imgViewer = new ViewerServerControl();
            viewer.Controls.Add(imgViewer);   // Add viewer to Placeholder
}

The ascx "vwHardCopy" is

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="vwHardCopy.ascx.cs"
    Inherits="OriginsNetwork.ImageViewer.vwHardCopy" %>
<%@ Register TagPrefix="telerik" Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" %>
 
<telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false"
    ReloadOnShow="true" runat="server" EnableShadow="true" Width="1500px" Height="500px">
    <Windows>
        <telerik:RadWindow runat="server" ID="RadWindow_NavigateUrl" NavigateUrl="Dialog.aspx"
        Modal="false" Width="300px" Height="250px" Left="0px" Title = "Title of Window">
     </telerik:RadWindow>     
    </Windows>
</telerik:RadWindowManager>
<div id="hardcopy" style="margin-top: 30px;">
<asp:ImageButton ID="btnDialog" ImageUrl "/images/buttons/order-original-red.gif" OnClientClick = "openWinNavigateUrl(); return false;" runat="server"></asp:ImageButton>  
<script type="text/javascript">
            function openWinNavigateUrl() {
                $find("<%=RadWindow_NavigateUrl.ClientID %>").show();
            }
</script>
</div>

the Window is shown but in FireFox, it is behind the Viewer and in IE8 is doesnt get shown at all and seems to do a postback.  I havent tested it with IE9 yet.

Can anyone point me in the right direction to try to debug this or see what is going on.

Thanks for looking
Roger
Marin Bratanov
Telerik team
 answered on 19 Dec 2012
3 answers
118 views
Hi

I have a TreeView inside of a ComboBox and have turned on EnableDragAndDrop and EnableDragAndDropBetweenNodes.  I'm able to drag the nodes and drop them, but I am not getting the little underline image that normally shows up when you move a node between two other nodes to let you know where you will be dropping the dragging node.

Looking at the html, it looks like this is handled by a div with the class "rtDragClue", which has it's visibility toggled, but is not showing up anywhere that I can see it.

Has anyone had this problem and been able to fix it?

Thanks
Boyan Dimitrov
Telerik team
 answered on 19 Dec 2012
1 answer
65 views
I'm trying to drag one appointment up, and another appointment will also move up.
I'm using the following codes.  It changes the end time of another appointment, but the scheduler doesn't show any change:

function OnClientAppointmentMoveEnd(sender, eventArgs) {
      //if available end time is less then preferred end time, the prefered end time should match the available end time
      for (var i = 0; i < apps.get_count(); i++) {
          if (apps._array[i]._subject == 'preferred') {
              if (apps._array[i].get_end().format('yyyy/mm/dd HH:mm:ss') > newEndTime.format('yyyy/mm/dd HH:mm:ss')) {
                  apps._array[i].set_end(newEndTime);
                  break;
              }

          }
      } 
}

Please refer to the PNG files

Plamen
Telerik team
 answered on 19 Dec 2012
3 answers
151 views
Hello,

I have an issue with the PageSize property on a radgrid not being retained when I have detail tables in my grid.  Essentially everything works as expected when I remove the detail tables, however if the detail tables are added to the main grid the PageSize property is always set to the default value in the NeedDatasource event.  In the PageSizeChanged event I do see that the e.NewPageSize is set to the new page size, but it is not correct in the NeedDatasource.  Again if I remove both of the detail tables, the PageSize property works as expected.  Thanks.

Template:
<telerik:RadAjaxLoadingPanel ID="radLoading" runat="server">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadWindowManager ID="radWindowManager" runat="server">
    </telerik:RadWindowManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgExportTypes">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgExportTypes" LoadingPanelID="radLoading" />
                    <telerik:AjaxUpdatedControl ControlID="pnlAlert" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:Panel ID="pnlAlert" runat="server">
        <asp:Label ID="lbMessage" runat="server" CssClass="success" />
    </asp:Panel>
    <telerik:RadGrid ID="rgExportTypes" runat="server" AutoGenerateColumns="False" CellSpacing="0"
        ShowGroupPanel="true" GridLines="None" AllowPaging="True" AllowCustomPaging="True"
        AllowFilteringByColumn="True" AllowSorting="True" Width="100%" OnInsertCommand="rgExportTypes_InsertCommand"
        OnNeedDataSource="rgExportTypes_NeedDataSource" OnUpdateCommand="rgExportTypes_UpdateCommand"
        OnDetailTableDataBind="rgExportTypes_DetailTableDataBind" OnDeleteCommand="rgExportTypes_DeleteCommand"
        OnItemDataBound="rgExportTypes_ItemDataBound">
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="true">
            <Selecting CellSelectionMode="None"></Selecting>
        </ClientSettings>
        <MasterTableView AllowFilteringByColumn="true" AllowMultiColumnSorting="true" CommandItemDisplay="Top"
            CommandItemSettings-AddNewRecordText="Add Export Type" Name="ExportType" DataKeyNames="Id">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <DetailTables>
                <telerik:GridTableView DataKeyNames="Id" runat="server" CommandItemDisplay="Top"
                    InsertItemPageIndexAction="ShowItemOnCurrentPage" CommandItemSettings-AddNewRecordText="Add Column"
                    HierarchyLoadMode="ServerOnDemand" AllowPaging="False" AllowFilteringByColumn="False"
                    AllowSorting="False" Name="Column" NoDetailRecordsText="No columns associated with this export type.">
                    <Columns>
                        <telerik:GridBoundColumn DataField="ColumnHeader" FilterControlAltText="Filter column1 column"
                            HeaderText="Column Header" UniqueName="ColumnHeader">
                        </telerik:GridBoundColumn>
                        <telerik:GridNumericColumn DataField="ColumnNumber" FilterControlAltText="Filter column1 column"
                            HeaderText="Column Number" UniqueName="ColumnNumber">
                        </telerik:GridNumericColumn>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton">
                            <ItemStyle Width="30px" />
                            <HeaderStyle Width="30px" />
                        </telerik:GridEditCommandColumn>
                    </Columns>
                    <EditFormSettings EditFormType="WebUserControl" UserControlName="/controls/forms/ExportTypeColumnForm.ascx">
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                        </EditColumn>
                    </EditFormSettings>
                    <DetailTables>
                        <telerik:GridTableView DataKeyNames="Id" runat="server" InsertItemPageIndexAction="ShowItemOnCurrentPage"
                            CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand" AllowPaging="False"
                            AllowFilteringByColumn="False" InsertItemDisplay="Bottom" AllowSorting="True"
                            AllowMultiColumnSorting="True" CommandItemSettings-AddNewRecordText="Add Column Values"
                            Name="ColumnValue" NoDetailRecordsText="No values from been associated with this column.">
                            <Columns>
                                <telerik:GridBoundColumn DataField="ColumnName" FilterControlAltText="Filter column1 column"
                                    HeaderText="Column Name" UniqueName="ColumnName">
                                </telerik:GridBoundColumn>
                                <telerik:GridNumericColumn DataField="ColumnValueOrder" FilterControlAltText="Filter column2 column"
                                    HeaderText="Column Value Order" UniqueName="ColumnValueOrder">
                                </telerik:GridNumericColumn>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton">
                                    <ItemStyle Width="60px" />
                                    <HeaderStyle Width="60px" />
                                </telerik:GridEditCommandColumn>
                                <telerik:GridButtonColumn ConfirmText="Delete Column Value: [[ColumnName]]?" ConfirmDialogType="RadWindow"
                                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px"
                                    ConfirmDialogWidth="300px" UniqueName="DeleteColumn" />
                            </Columns>
                            <EditFormSettings EditFormType="WebUserControl" UserControlName="/controls/forms/ExportTypeColumnValueForm.ascx">
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                </EditColumn>
                            </EditFormSettings>
                        </telerik:GridTableView>
                    </DetailTables>
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter column column"
                    HeaderText="Name" UniqueName="Name" FilterControlWidth="250px">
                    <ItemStyle Width="250px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ExportFileType" FilterControlAltText="Filter column1 column"
                    HeaderText="ExportFileType" UniqueName="ExportFileType" FilterControlWidth="100px">
                    <ItemStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Product" FilterControlAltText="Filter column2 column"
                    HeaderText="Product" UniqueName="Product" FilterControlWidth="75px">
                    <ItemStyle Width="75px" />
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="PartnerFormat" FilterControlAltText="Filter TemplateColumn2 column"
                    HeaderText="Patrtner Format" UniqueName="PartnerFormat" FilterControlWidth="30px"
                    SortExpression="PartnerFormat">
                    <ItemStyle Width="30px" />
                    <ItemTemplate>
                        <%# GetBool(Eval("PartnerFormat"))%>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn DataField="HasHeaderRow" FilterControlAltText="Filter TemplateColumn3 column"
                    HeaderText="Has Header Row" UniqueName="HasHeaderRow" FilterControlWidth="30px"
                    SortExpression="HasHeaderRow">
                    <ItemStyle Width="30px" />
                    <ItemTemplate>
                        <%# GetBool(Eval("HasHeaderRow"))%>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridEditCommandColumn ButtonType="ImageButton">
                    <ItemStyle Width="30px" />
                    <HeaderStyle Width="30px" />
                </telerik:GridEditCommandColumn>
            </Columns>
            <EditFormSettings EditFormType="WebUserControl" UserControlName="/controls/forms/ExportTypeForm.ascx">
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>

Code Behind:

public partial class partners_export_types_default : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetLogger(typeof(partners_export_types_default));
 
    protected void Page_Load(object sender, EventArgs e)
    {
        log.Debug("Page_Load");
        switch (Request["Type"])
        {
            case "XDates":
                ltExportHeader.Text = "X-Dates Export Types";
                break;
            default:
                Response.Redirect("~/");
                break;
        }
    }
    protected void rgExportTypes_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        log.Debug("rgExportTypes_NeedDataSource - page size(" + rgExportTypes.PageSize + ")");
        int startIndex = rgExportTypes.CurrentPageIndex * rgExportTypes.PageSize;
 
        string queryString = @"SELECT VALUE e FROM ColeAdminContext.ExportTypes As e ";
 
        if (!string.IsNullOrEmpty(rgExportTypes.MasterTableView.FilterExpression))
        {
            queryString += " where " + rgExportTypes.MasterTableView.FilterExpression.FormatWhereColumns("e", rgExportTypes.MasterTableView.Columns);
        }
 
        ColeAdminContext ctx = new ColeAdminContext();
        ObjectQuery<Cole.Admin.Entities.ExportType> exportCount = new ObjectQuery<Cole.Admin.Entities.ExportType>(queryString, ((IObjectContextAdapter)ctx).ObjectContext);
        rgExportTypes.VirtualItemCount = exportCount.Count();
 
        if (rgExportTypes.MasterTableView.SortExpressions.Count > 0)
        {
            queryString += "order by " + rgExportTypes.MasterTableView.SortExpressions.GetSortString().FormatOrderColumns("e", rgExportTypes.MasterTableView.Columns);
        }
        else
        {
            queryString += "order by e.Name";
        }
        log.Debug("query string(" + queryString + ")");
        ObjectQuery<Cole.Admin.Entities.ExportType> exportLists = new ObjectQuery<Cole.Admin.Entities.ExportType>(queryString, ((IObjectContextAdapter)ctx).ObjectContext);
        rgExportTypes.DataSource = exportLists.Skip(startIndex).Take(rgExportTypes.PageSize).ToList();
    }
    protected void rgExportTypes_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        UserControl form = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
 
        if (e.Item.OwnerTableView.Name == "ExportType")
        {
            Cole.Admin.Entities.ExportType exportType = new Cole.Admin.Entities.ExportType();
            exportType.Name = (form.FindControl("txtName") as TextBox).Text;
            exportType.ExportFileType = (form.FindControl("ddlExportFileType") as DropDownList).SelectedValue;
            exportType.Product = (form.FindControl("ddlProducts") as DropDownList).SelectedValue;
            exportType.PartnerFormat = (form.FindControl("cbPartnerFormat") as CheckBox).Checked;
            exportType.HasHeaderRow = (form.FindControl("cbHasHeaderRow") as CheckBox).Checked;
 
            ColeAdminContext ctx = new ColeAdminContext();
            ctx.ExportTypes.Add(exportType);
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Added Export Type");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Added Export Type: " + exportType.Name;
            lbMessage.Visible = true;
        }
 
        if (e.Item.OwnerTableView.Name == "Column")
        {
            int id = Convert.ToInt32(e.Item.OwnerTableView.ParentItem.GetDataKeyValue("Id"));
            ExportTypeColumn column = new ExportTypeColumn();
            column.ColumnHeader = (form.FindControl("txtColumnHeader") as TextBox).Text;
            column.ColumnNumber = Convert.ToInt16((form.FindControl("ddlColumnNumber") as DropDownList).SelectedValue);
            column.ExportTypeId = id;
 
            ColeAdminContext ctx = new ColeAdminContext();
            foreach (ExportTypeColumn existingColumn in ctx.ExportTypeColumns.Where(c => c.ColumnNumber >= column.ColumnNumber && c.ExportTypeId == id))
            {
                existingColumn.ColumnNumber++;
            }
 
            ctx.ExportTypeColumns.Add(column);
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Added Column");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Added Column: " + column.ColumnHeader;
            lbMessage.Visible = true;
 
        }
 
        if (e.Item.OwnerTableView.Name == "ColumnValue")
        {
            int id = Convert.ToInt32(e.Item.OwnerTableView.ParentItem.GetDataKeyValue("Id"));
            ExportTypeColumnValue columnValue = new ExportTypeColumnValue();
            columnValue.ColumnName = (form.FindControl("ddlColumnName") as DropDownList).SelectedValue;
            columnValue.ColumnValueOrder = Convert.ToInt16((form.FindControl("ddlColumnValueOrder") as DropDownList).SelectedValue);
            columnValue.ExportTypeColumnId = id;
 
            ColeAdminContext ctx = new ColeAdminContext();
            foreach (ExportTypeColumnValue existingColumn in ctx.ExportTypeColumnValues.Where(c => c.ColumnValueOrder >= columnValue.ColumnValueOrder && c.ExportTypeColumnId == id))
            {
                existingColumn.ColumnValueOrder++;
            }
 
            ctx.ExportTypeColumnValues.Add(columnValue);
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Added Column Value");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Added Column Value: " + columnValue.ColumnName;
            lbMessage.Visible = true;
 
        }
    }
    protected void rgExportTypes_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        log.Debug("rgExportTypes_UpdateCommand(" + e.Item.OwnerTableView.Name + ")");
        GridEditableItem editedItem = e.Item as GridEditableItem;
        UserControl form = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
 
        if (e.Item.OwnerTableView.Name == "ExportType")
        {
            ColeAdminContext ctx = new ColeAdminContext();
            int id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"]);
 
            Cole.Admin.Entities.ExportType exportType = ctx.ExportTypes.Where(et => et.Id == id).Single();
            exportType.Name = (form.FindControl("txtName") as TextBox).Text;
            exportType.ExportFileType = (form.FindControl("ddlExportFileType") as DropDownList).SelectedValue;
            exportType.Product = (form.FindControl("ddlProducts") as DropDownList).SelectedValue;
            exportType.PartnerFormat = (form.FindControl("cbPartnerFormat") as CheckBox).Checked;
            exportType.HasHeaderRow = (form.FindControl("cbHasHeaderRow") as CheckBox).Checked;
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Updated Export Type");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Updated Export Type: " + exportType.Name;
            lbMessage.Visible = true;
        }
 
        if (e.Item.OwnerTableView.Name == "Column")
        {
            int parentId = Convert.ToInt32(e.Item.OwnerTableView.ParentItem.GetDataKeyValue("Id"));
            int id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"]);
            ColeAdminContext ctx = new ColeAdminContext();
            ExportTypeColumn column = ctx.ExportTypeColumns.Where(c => c.Id == id).Single();
 
            int newColumnNumber = Convert.ToInt16((form.FindControl("ddlColumnNumber") as DropDownList).SelectedValue);
            if (column.ColumnNumber > newColumnNumber)
            {
                foreach (ExportTypeColumn existingColumn in ctx.ExportTypeColumns.Where(c => c.ColumnNumber >= newColumnNumber && c.ExportTypeId == parentId))
                {
                    existingColumn.ColumnNumber++;
                }
            }
 
            if (column.ColumnNumber < newColumnNumber)
            {
                foreach (ExportTypeColumn existingColumn in ctx.ExportTypeColumns.Where(c => c.ColumnNumber <= newColumnNumber && c.ExportTypeId == parentId))
                {
                    existingColumn.ColumnNumber--;
                }
            }
 
            column.ColumnHeader = (form.FindControl("txtColumnHeader") as TextBox).Text;
            column.ColumnNumber = (short)newColumnNumber;
 
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Added Column");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Added Column: " + column.ColumnHeader;
            lbMessage.Visible = true;
 
        }
 
        if (e.Item.OwnerTableView.Name == "ColumnValue")
        {
            ColeAdminContext ctx = new ColeAdminContext();
            int parentId = Convert.ToInt32(e.Item.OwnerTableView.ParentItem.GetDataKeyValue("Id"));
            int id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"]);
            ExportTypeColumnValue columnValue = ctx.ExportTypeColumnValues.Where(v => v.Id == id).Single();
 
            int newColumnOrder = Convert.ToInt16((form.FindControl("ddlColumnValueOrder") as DropDownList).SelectedValue);
            if (columnValue.ColumnValueOrder > newColumnOrder)
            {
                foreach (ExportTypeColumnValue existingColumn in ctx.ExportTypeColumnValues.Where(c => c.ColumnValueOrder >= newColumnOrder && c.ExportTypeColumnId == parentId))
                {
                    existingColumn.ColumnValueOrder++;
                }
            }
 
            if (columnValue.ColumnValueOrder < newColumnOrder)
            {
                foreach (ExportTypeColumnValue existingColumn in ctx.ExportTypeColumnValues.Where(c => c.ColumnValueOrder <= newColumnOrder && c.ExportTypeColumnId == parentId))
                {
                    existingColumn.ColumnValueOrder--;
                }
            }
 
            columnValue.ColumnName = (form.FindControl("ddlColumnName") as DropDownList).SelectedValue;
            columnValue.ColumnValueOrder = (short)newColumnOrder;
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(Page.User.Identity.Name), "Updated Column Value");
            ctx.AuditEvents.Add(ae);
 
            ctx.SaveChanges();
            lbMessage.Text = "Successfully Updated Column Value: " + columnValue.ColumnName;
            lbMessage.Visible = true;
 
        }
    }
    protected void rgExportTypes_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        log.Debug("rgExportTypes_DetailTableDataBind(" + e.DetailTableView.Name + ")");
        GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
        if (parentItem.Edit)
        {
            return;
        }
 
        if (e.DetailTableView.Name == "Column")
        {
            int id = Convert.ToInt32(parentItem.GetDataKeyValue("Id"));
            ColeAdminContext ctx = new ColeAdminContext();
 
            List<ExportTypeColumn> columns = ctx.ExportTypeColumns.Where(u => u.ExportTypeId == id).OrderBy(c => c.ColumnNumber).ToList();
 
            e.DetailTableView.DataSource = columns;
            e.DetailTableView.VirtualItemCount = columns.Count;
             
        }
 
        if (e.DetailTableView.Name == "ColumnValue")
        {
            int id = Convert.ToInt32(parentItem.GetDataKeyValue("Id"));
            ColeAdminContext ctx = new ColeAdminContext();
 
            List<ExportTypeColumnValue> values = ctx.ExportTypeColumnValues.Where(v => v.ExportTypeColumnId == id).OrderBy(c => c.ColumnValueOrder).ToList();
            e.DetailTableView.DataSource = values;
            e.DetailTableView.VirtualItemCount = values.Count;
        }
    }
    protected void rgExportTypes_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            if (e.Item.DataItem is ExportTypeColumnValue)
            {
                ExportTypeColumnValue exportTypeColumn = (ExportTypeColumnValue)e.Item.DataItem;
                WebControl deleteButton = (WebControl)((GridDataItem)e.Item)["DeleteColumn"].Controls[0];
                string clickHandler = deleteButton.Attributes["onclick"];
                deleteButton.Attributes["onclick"] = clickHandler.Replace("[[ColumnName]]", exportTypeColumn.ColumnName);
            }
        }
    }
    protected void rgExportTypes_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item.OwnerTableView.Name == "ColumnValue")
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
 
            int id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"]);
            ColeAdminContext ctx = new ColeAdminContext();
 
            ExportTypeColumnValue exportColumnValue = ctx.ExportTypeColumnValues.Where(r => r.Id == id).Single();
            ctx.ExportTypeColumnValues.Remove(exportColumnValue);
 
            AuditEvent ae = AuditEvent.Info(Convert.ToInt32(User.Identity.Name), "Remove Column Value");
            ctx.AuditEvents.Add(ae);
            ctx.SaveChanges();
 
            lbMessage.Text = "Successfully Deleted Column Value: " + exportColumnValue.ColumnName;
            lbMessage.Visible = true;
 
            ctx.SaveChanges();
        }
    }
 
    protected string GetBool(object boolToFormat)
    {
        if (boolToFormat != null)
        {
            if ((bool)boolToFormat)
            {
                return "<span class='label label-success'>YES</span>";
            }
            else
            {
                return "<span class='label label-important'>NO</span>";
            }
        }
        else
        {
            return "";
        }
    }
    protected void rgExportTypes_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
    {
        log.Debug("rgExportTypes_PageSizeChanged");
        log.Debug("new page size(" + e.NewPageSize + ") page size(" + rgExportTypes.PageSize + ")");
    }
}
Maria Ilieva
Telerik team
 answered on 19 Dec 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?