Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
102 views
I'm using the KendoUI Grid with nested detailed grids in a KendoUI Tab control.  In one of the child grids I need to include a custom column as a link to a different page.  I need to pass the current row ID as a querystring.  The link is drawing but is creating the URL like this: https://localhost:44322/Admin/CompanyModuleAppRole?moduleID=undefined

The routing is working as expected and the controller is getting the request and drawing the new page.  Here is the cshtml (line 150 is the problem)
Thanks for any help out there.

@using InnovareClinicianDesktop.Areas.Admin.ViewModels
@model InnovareClinicianDesktop.Areas.Admin.ViewModels.CompanyViewModelResults
 
@{
    ViewBag.Title = "Details";
}
 
<h2>Manage records in the Company table.</h2>
<div id="example" class="k-content">
    @RenderCompanyViewModel()
</div>
 
<h1>Other options:</h1>
@Html.ActionLink("Return to Application Management", "Index", "Home")
 
 
@helper RenderCompanyViewModel()
{
    @(Html.Kendo().Grid<CompanyViewModel>(Model.CompanyViewModels)
        .Name("grid")
        .Columns(columns =>
        {
            columns.Bound(p => p.CompanyName).Width(127);
            columns.Bound(p => p.IsActive).Width(40);
            columns.Bound(p => p.CreatedDate).Width(80).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.CreatedBy).Width(80);
            columns.Bound(p => p.LastModifiedDate).Width(80).Format("{0:MM/dd/yyyy}");
            columns.Bound(p => p.LastModifiedBy).Width(80);
            columns.Command(command =>
            {
                command.Edit();
                command.Destroy();
            }).Width(160);
        })
        .ToolBar(toolbar => toolbar.Create())
        .Editable(editable => editable.Mode(GridEditMode.PopUp))
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .Sortable(sortable => sortable
            .AllowUnsort(true)
            .SortMode(GridSortMode.MultipleColumn))
        .Scrollable()
        .ClientDetailTemplateId("template")
        .Resizable(resize => resize.Columns(true))
        .Selectable(sel => sel.Mode(GridSelectionMode.Single))
        .HtmlAttributes(new { style = "height:530px;" })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Events(events => events.Error("error_handler"))
            .Model(model => { model.Id(p => p.CompanyID); model.Field(p => p.CompanyID).DefaultValue(System.Guid.Empty); })
            .Create(create => create.Action("EditingPopup_Create", "Company", new { area = "Admin" }))
            .Read(read => read.Action("EditingPopup_Read", "Company", new { area = "Admin" }))
            .Update(update => update.Action("EditingPopup_Update", "Company", new { area = "Admin" }))
            .Destroy(update => update.Action("EditingPopup_Destroy", "Company", new { area = "Admin" }))
        )
    )
}
 
<script id="template" type="text/kendo-tmpl">
    @(Html.Kendo().TabStrip()
            .Name("tabStrip_#=CompanyID#")
            .SelectedIndex(0)
            .Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
            .Items(items =>
            {
                items.Add().Text("Users").Content(@<text>
                    @(Html.Kendo().Grid<InnovareClinicianDesktop.Areas.Admin.ViewModels.ApplicationObjectViewModel>()
                        .Name("applicationObject_#=CompanyID#")
                        .Columns(columns =>
                        {
                            columns.Bound(u => u.ObjectID).Title("ID").Width(56);
                            columns.Bound(u => u.ObjectName).Width(110);
                            columns.Bound(u => u.ObjectType).Width(30);
                            columns.Bound(u => u.FirstName).Width(190);
                            columns.Bound(u => u.LastName).Width(40);
                            columns.Bound(u => u.EmailAddress).Width(160);
                            columns.Bound(u => u.CreatedDate).Width(80).Format("{0:MM/dd/yyyy}");
                            columns.Bound(u => u.CreatedBy).Width(160);
                        })
                        .ToolBar(toolbar =>
                        {
                            toolbar.Custom().Text("Manage Users").Name("manageApplications").Action("Index", "ApplicationObject", new { companyID = "#=CompanyID#" });
                        })
                        .Pageable(pageable => pageable
                            .Refresh(true)
                            .PageSizes(true)
                            .ButtonCount(5))
                        .Sortable(sortable => sortable
                            .AllowUnsort(true)
                            .SortMode(GridSortMode.MultipleColumn))
                        .Scrollable()
                        .Resizable(resize => resize.Columns(true))
                        .Selectable(sel => sel.Mode(GridSelectionMode.Single))
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .PageSize(5)
                            .Read(u => u.Action("ToolbarTemplate_ApplicationObjects", "Company", new { companyID = "#=CompanyID#" }))
                        )
                        .ToClientTemplate())
                </text>
                );
                items.Add().Text("Applications").Content(@<text>
                    @(Html.Kendo().Grid<InnovareClinicianDesktop.Areas.Admin.ViewModels.CompanyApplicationViewModel>()
                        .Name("companyApplication_#=CompanyID#")
                        .Columns(columns =>
                        {
                            columns.Bound(a => a.CompanyApplicationID).Title("ID").Width(56);
                            columns.Bound(a => a.ApplicationID).Width(110);
                            columns.Bound(a => a.IsActive).Width(30);
                            columns.Bound(a => a.CreatedBy).Width(160);
                            columns.Bound(a => a.CreatedDate).Width(80).Format("{0:MM/dd/yyyy}");
                            columns.Bound(a => a.LastModifiedBy).Width(160);
                            columns.Bound(a => a.LastModifiedDate).Width(80).Format("{0:MM/dd/yyyy}");
                        })
                        .ToolBar(toolbar =>
                        {
                            toolbar.Custom().Text("Manage Applications").Name("manageApplications").Action("Index", "CompanyApplication", new { companyID = "#=CompanyID#" });
                        })
                        .Pageable(pageable => pageable
                            .Refresh(true)
                            .PageSizes(true)
                            .ButtonCount(5))
                        .Sortable(sortable => sortable
                            .AllowUnsort(true)
                            .SortMode(GridSortMode.MultipleColumn))
                        .Scrollable()
                        .Resizable(resize => resize.Columns(true))
                        .Selectable(sel => sel.Mode(GridSelectionMode.Single))
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .PageSize(5)
                            .Read(a => a.Action("ToolbarTemplate_CompanyApplications", "Company", new { companyID = "#=CompanyID#" }))
                        )
                        .ToClientTemplate())
                </text>
                );
                items.Add().Text("Modules").Content(@<text>
                    @(Html.Kendo().Grid<InnovareClinicianDesktop.Areas.Admin.ViewModels.CompanyModuleViewModel>()
                        .Name("companyModule_#=CompanyID#")
                        .Columns(columns =>
                        {
                            columns.Bound(m => m.CompanyModuleID).Title("ID").Width(56);
                            columns.Bound(m => m.IsActive).Width(30);
                            columns.Bound(m => m.CreatedBy).Width(160);
                            columns.Bound(m => m.CreatedDate).Width(80).Format("{0:MM/dd/yyyy}");
                            columns.Bound(m => m.LastModifiedBy).Width(160);
                            columns.Bound(m => m.LastModifiedDate).Width(80).Format("{0:MM/dd/yyyy}");
                            columns.Bound(m => m.ModuleID).ClientTemplate("<a href='" + Url.Action("Index", "CompanyModuleAppRole") + "?moduleID=" + "#= item.MethodID #" + "'>Manage Roles</a>").Width(100);
                        })
                        .ToolBar(toolbar =>
                        {
                            toolbar.Custom().Text("Manage Modules").Name("manageModules").Action("Index", "CompanyModule", new { companyID = "#=CompanyID#" });
                        })
                        .Pageable(pageable => pageable
                            .Refresh(true)
                            .PageSizes(true)
                            .ButtonCount(5))
                        .Sortable(sortable => sortable
                            .AllowUnsort(true)
                            .SortMode(GridSortMode.MultipleColumn))
                        .Scrollable()
                        .Resizable(resize => resize.Columns(true))
                        .Selectable(sel => sel.Mode(GridSelectionMode.Single))
                        .DataSource(dataSource => dataSource
                            .Ajax()
                            .PageSize(5)
                            .Read(m => m.Action("ToolbarTemplate_CompanyModules", "Company", new { companyID = "#=CompanyID#" }))
                        )
                    .ToClientTemplate())
                </text>
                );
            })
            .ToClientTemplate())
</script>
 
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
 
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
 
    function onComplete(e) {
        if (e.name == "Delete") {
            var result = e.response.result;
            if (result == true)
                $("#Items").data("tGrid").rebind();
            else {
                alert("Error on deleting")
            }
        }
    }
</script>

James
Top achievements
Rank 1
 answered on 31 Dec 2014
5 answers
369 views

Hi
Here's 2 different typed columns. Both have DataField specified

<telerik:GridBoundColumn DataField="ID" UniqueName="ID" Visible="False" > 
</telerik:GridBoundColumn> 
 
<telerik:GridTemplateColumn DataField="Name" HeaderText="Name" UniqueName="NameColumn">  
<ItemTemplate><%# DataBinder.Eval(Container.DataItem, "Name") %></ItemTemplate>   
<EditItemTemplate> 
<asp:TextBox ID="tbName" runat="server" SkinID="GeneralTextBox" Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:TextBox>      
</EditItemTemplate>    
</telerik:GridTemplateColumn>   
 


However only "ID" exists in SavedOldValues collection (ItemCommand event):
Telerik.Web.UI.GridDataItem dataItem = e.Item as Telerik.Web.UI.GridDataItem;  
dataItem.SavedOldValues["ID"//this always have a value  
dataItem.SavedOldValues["Name"// this is not exists 


Why 'Name' is not contains in SavedOldValues collection when I use GridTemplateColumn?
I'm forced to do selection from dataset by ID to get original 'Name' value

Scott
Top achievements
Rank 1
 answered on 30 Dec 2014
2 answers
241 views
Hi,
I have a Rad grid with a Detail Grid. Both the parent and child grid are in BatchEdit mode. I do the validation at server side and display the error messages through RadWindow.

When a error is displayed, the grid loses the entries and reverts to its original state. How do I keep the values during the Ajax post backs? I tried setting the event.Cancelled = true on BatchEditCommand event handler. It doesn't help.

Any example will be useful.

Thanks,
Sambath
Sambathraj
Top achievements
Rank 1
 answered on 30 Dec 2014
1 answer
88 views
 Hi All.
                   I have a question regarding using RadClientDataSource tied to asmx service and also use Command Item EDIT something like this shown in the link  <http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/commanditem/defaultcs.aspx>  but use RadClientDataSource and also have custom EDIT FORM type.Example shown on telerik website use RadClientDataSource but have only BATCH EDIT MODE. so i was wondering if you have a way to use custom edit form instead of batch edit.I am facing lot of issue implementing this. if you click on command item CommandItemTemplate edit button using RadClientDataSource the custom edit form shows up somehow but the data on grid disappears and throws lot of javascript errors  like " Unable to get property 'get_batchEditingManager' of undefined or null reference ,Error: Unable to get property '_virtualization' of undefined or null reference, Unable to get property 'get_clientDataSource' of undefined or null reference " .
please let me know, if anyone ran into similar issue. i can post code if i need to.  so long story short... i want to use CommandItemTemplate EDIT UPDATE OPTION using RadClientDataSource Is it possible ?
Thanks in advance.
Saif

Angel Petrov
Telerik team
 answered on 30 Dec 2014
1 answer
87 views
I'm trying to store the pivotgrid state in a database but I don't know the  layout of the table.

I'm assuming it's a simple table with a string key and a string data field. Is this correct?
Laurens
Top achievements
Rank 1
 answered on 30 Dec 2014
3 answers
52 views
I have radGrid with datetime field which I filter by default range filters. here is my markup for this field

<telerik:GridDateTimeColumn DataField="REGISTRATION_DATE" EnableRangeFiltering="true" EnableTimeIndependentFiltering="true" FilterControlWidth="90px" FilterControlAltText="Filter VatQty column" HeaderText="თარიღი" SortExpression="REGISTRATION_DATE" UniqueName="REGISTRATION_DATE" DataType="System.DateTime" CurrentFilterFunction="EqualTo" ShowFilterIcon="true" AutoPostBackOnFilter="True">
                </telerik:GridDateTimeColumn>  

When I filter by one day then all the records that have time between 23:59:00 and 23:59:59 in the same day doesn't return by filter. 
Do you know of any workaround or fix for this problem?
Eyup
Telerik team
 answered on 30 Dec 2014
4 answers
354 views
Hi,

I am using the radasyncupload in a RadGrid.The MasterTavleView is set up to EditMode="Batch" and i use a GridtemplateColumn for the radasyncupload :

<telerik:GridTemplateColumn HeaderText="AttachedFile" UniqueName="UploadColumn">
<ItemTemplate>
<telerik:RadListBox runat="server" ID="listBox1">
 <ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "Url")%>">Lien <%# DataBinder.Eval(Container.DataItem,"Name")%></a>
 </ItemTemplate>
</telerik:RadListBox>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadAsyncUpload runat="server" D="AsyncUpload1" OnFileUploaded="AsyncUpload1_FileUploaded" AllowedFileExtensions="jpg,jpeg,png,gif,pdf" MaxFileSize="1048576"  MultipleFileSelection="Automatic">
</telerik:RadAsyncUpload>
</EditItemTemplate>
</telerik:GridTemplateColumn>

When the user finish to edit a row i can find the RadAsync control in  BatchEditCommand event :

protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        foreach (GridBatchEditingCommand command in e.Commands)
        {
            if ((command.Type == GridBatchEditingCommandType.Update))
            {
                Hashtable newValues = command.NewValues;
 
                if (newValues != null)
                {
                    RadAsyncUpload asyncUpload = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_UploadColumn").FindControl("AsyncUpload1") as RadAsyncUpload;
                    //Here i need to get files by row or DataKeyNames
                    foreach (var item in asyncUpload.UploadedFiles)
                    {
 
                    }
                }
            }
        }
    }


The radAsyncControl show me all the file uploaded so i can't get the file uploaded by row. I need to know files uploaded by row to save them in database.
Is there a way to get file uploaded by row or DataKeyNames with EdimtMode="Batch" ?




Konstantin Dikov
Telerik team
 answered on 30 Dec 2014
3 answers
1.2K+ views
I am using the below code for displaying crew qualification in a radgrid.

<telerik:GridTemplateColumn DataField="CrewQualification"
FilterControlAltText="Filter CrewQualification column" HeaderText="Crew Details"
UniqueName="CrewQualification" FilterControlWidth="40px">
<ItemTemplate>
<asp:HyperLink ID="CrewInfoLink" Font-Underline="true" runat="server" Text="Edit" CssClass="mousechange"></asp:HyperLink>
<asp:Label ID ="CrewLabel" runat="server" Text="Edit" ></asp:Label>
</ItemTemplate>
<HeaderStyle Width="80px" />
</telerik:GridTemplateColumn>

But the filter in that column is not working despite of adding 'AllowFilteringByColumn,AllowFiltering,AutoPostBackOnFilter' and also 'Datatype' properties to this grid template column.Please help me in this
Konstantin Dikov
Telerik team
 answered on 30 Dec 2014
4 answers
139 views
I am using a hierarchical radgrid with scrolling detail tables. The master table itself does not have a horizontal scrollbar, only the the detail tables. After exporting and upon the next postback that refreshes the screen, my radgrid's detail table widths are expanded to their full width so that the scroll bars on the detail table become disabled (because the width of the div is equivalent to the width of the content) and the master table generates a horizontal scroll bar to compensate for the increase in width.

I know that actual export commands are causing the issue, because if I comment them out, the problem ceases to occur. I am not performing any modifications to the radgrid from the auto-fired events once the exportToX command is run. So the source of the issue is definitely in the Telerik exportTo commands.

Now, I figured that I would be able to easily patch over the underlying issue by modifying the css for specific radgrid-created class, such as rgMasterTable. Unfortunately, the screen will not render my now 10em table as 10 ems, but will continue to make it 100% width no matter how many "!importants;" I use. I can use developer tools to see that, indeed, that the source code for the table's in-line CSS is 10em. Unfortunately, it is not rendered as such. I would also be willing to wager that the issue is not in how IE9 interprets HTML and CSS. I am at a loss for what to attempt next though.

So, to recap, scrollable detail tables in an Ajaxified RadGrid ignores CSS on postback after exportToX command.
Zachary
Top achievements
Rank 1
 answered on 29 Dec 2014
2 answers
462 views
Good afternoon,

I have the following which nicely formats the exported column to currency (ex. $12,345.60):
((GridBoundColumn)exportGrid.Columns[13]).DataFormatString = "{0:C2}";

When the Excel export is done (BIFF format), the data comes out as text as "$12,345.60".  It looks pretty, but the user wants to be able to perform calculations.

I have changed the text value in ItemDataBound to be preceded with an equal (=), which makes the exported data calculate right, but now the complaint is that it doesn't look like currency.  It shows 12345.6.

Is there a way to get a BIFF export to look like currency and be treated as a numeric for calculations?

Thanks,
Steve
SickPup404
Top achievements
Rank 1
 answered on 29 Dec 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
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
Iron
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?