Hi ,
this is my grid:
@using TaskManagementUI.Models
@model InfoModel
<link href="~/Css/SavedManagementProjects.css" rel="stylesheet" />
<script src="~/JavaScript/SavedManagementProjects.js"></script>
<script type="text/kendo" id="DevelopersTemplate">
<ul>
#for(var i = 0; i< data.length; i++){#
<li title="#:data[i].Name#">#:data[i].Name#</li>
#}#
</ul>
</script>
@Html.Partial("~/Views/Shared/Info.cshtml", Model)
@(Html.Kendo().Grid<ProjectViewModel>()
.Name("GridManagementProjects")
.Columns(columns =>
{
columns.Bound(c => c.ProductID).Title("Product Id").Hidden();
columns.Bound(c => c.ProductName).Title("Product Name").Hidden();
columns.Bound(c => c.Name).Title("Name").Width(120)
.Filterable(f => f.UI("NamesProjectFilter")
.Mode(GridFilterMode.Row)
.Extra(false).Messages(m => m.Info("Show items with this name"))
.Operators(operators => operators
.ForString(str => str.Clear()
.IsEqualTo("Is equal to"))));
columns.Bound(c => c.Leader.Name).EditorTemplateName("LeaderEditor").Title("Leader").Width(150)
.Filterable(f => f.UI("developersFilter")
.Mode(GridFilterMode.Row)
.Extra(false).Messages(m => m.Info("Show items with this leader"))
.Operators(operators => operators
.ForString(str => str.Clear()
.IsEqualTo("Is equal to"))));
columns.Bound(c => c.CodeReviewer.Name).EditorTemplateName("CodeReviewerEditor").Title("Code Reviewer").Width(150)
.Filterable(f => f.UI("developersFilter")
.Mode(GridFilterMode.Row)
.Extra(false).Messages(m => m.Info("Show items with this code reviewer"))
.Operators(operators => operators
.ForString(str => str.Clear()
.IsEqualTo("Is equal to"))));
columns.Bound(c => c.DevelopersDataSource).Width(200).ClientTemplate("#=DevelopersTemplate(DevelopersDataSource)#").EditorTemplateName("DevelopersEditor").Title("Developers")
.Filterable(f => f.UI("developersMultiFilter")
.Extra(false)
.Messages(m => m.Info("Show items contain these developers")))
.Sortable(false);
columns.Bound(c => c.PercentCompleted).Title("Percent Completed").Width(130).ClientTemplate("<div style='width:94px; height:94px;'><canvas id='projectManagementChart_#=ID #' width='94' height='94' style='display: block; width: 94px; height: 94px;'></canvas></div>");
columns.Bound(c => c.ActualStartDate).Title("Actual Start Date").Format("{0: MM/dd/yyyy}").Width(130);
columns.Bound(c => c.ActualEndDate).Title("Actual End Date").Format("{0: MM/dd/yyyy}").Width(130);
columns.Bound(c => c.EstimatedStartDate).Title("Estimated Start Date").EditorTemplateName("EstimatedStartDateEditor").Width(130).Format("{0: MM/dd/yyyy}");
columns.Bound(c => c.EstimatedEndDate).Title("Estimated End Date").EditorTemplateName("EstimatedEndDateEditor").Width(130).Format("{0: MM/dd/yyyy}");
columns.Bound(c => c.GitUrl).Title("Git Url").ClientTemplate("<a href='#= GitUrl #'>#= GitUrl #</a>").Width(120);
columns.Bound(c => c.StageId).Title("Stage").EditorTemplateName("StageEditor")
.Filterable(f => f.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.IsEqualTo("Is equal to"))))
.Width(110);
columns.Bound(c => c.Description).Title("Description").Width(250).HtmlAttributes(new { @class = "customCell" });
if (User.IsInRole("secSftwrProjMgmtDepl"))
{
columns.Bound(c => c.VstsBuildName).Title("Build Name").Width(120);
columns.Bound(c => c.VstsRepository).Title("Repository").Width(120);
columns.Bound(c => c.OctoProject).Title("Octopus Project").Width(120);
}
columns.Command(command =>
{
command.Custom("ADDTASK").Text("Add Task").Click("addTask");
command.Custom("DeployProject").Click("DeployProject").Text("Deploy");
if (User.IsInRole("secSftwrProjMgmtAdmn"))
{
command.Custom("CompleteProject").Click("CompleteProject").Text("Complete");
}
command.Custom("ProjectRequirements").Text("Requirements").Click("addProjectConditions");
}).Width(160).HtmlAttributes(new { id = "addTaskButton" });
columns.Command(command => { command.Edit().UpdateText(" ").Text(" ").CancelText(" "); if (User.IsInRole("secSftwrProjMgmtAdmn")) { command.Destroy().Text(" "); } }).Width(150);
})
.Groupable(g => g.Enabled(false))
.Filterable()
.ToolBar(toolbar =>
{
toolbar.Template(@<text>
<div class="toolbar" style="float: left">
@(Html.Kendo().DropDownList()
.Name("ProjectsByProduct")
.OptionLabel("SELECT PRODUCT")
.DataTextField("Name")
.DataValueField("ID")
.AutoBind(false)
.Events(e => e.Change("ProductGroupChange"))
.DataSource(ds =>
{
ds.Read("ProductList", "Product");
}))
<a class="k-button k-grid-excel k-button-icontext" href="#">
<span class="k-icon k-i-excel"></span>Export to Excel
</a>
@if (User.IsInRole("secSftwrProjMgmtAdmn"))
{
<a style="margin:0 "class="k-button k-button-icontext" onclick='addProjectAjax()' href="#">
<span class="k-icon k-i-add"></span> ADD PROJECT
</a>
}
</div>
</text>);
})
.Resizable(resize => resize.Columns(true))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Excel(excel => excel
.AllPages(true)
.FileName("Projects.xlsx")
.Filterable(true)
.ForceProxy(true)
.ProxyURL(Url.Action("FileExportSave", "Home")))
.Pageable(pager => pager
.Refresh(true)
.PageSizes(true)
.PageSizes(new int[] { 6, 15, 20 })
.ButtonCount(5))
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.MultipleColumn)
.Enabled(true);
})
.Scrollable()
.Events(events => events.FilterMenuOpen("onFilterMenuOpen").FilterMenuInit("FilterMenuInitProject").DataBound("onDataBoundSavedProjects").Cancel("createPieAfterCancellation").Edit("onProjectEdit").Save("onProjectSave").ExcelExport("exportProjects"))
.DataSource(dataSource => dataSource
.Ajax()
.Group(group => group.Add(p => p.ProductName))
.PageSize(20)
.Events(events => events.Error("errorHandlerProject"))
.Read(read => read.Action("GetSavedManagementProjects", "Project").Data("additionalData"))
.Model(model =>
{
model.Id(item => item.ID);
model.Field(a => a.ActualStartDate).Editable(false);
model.Field(a => a.ActualEndDate).Editable(false);
model.Field(a => a.PercentCompleted).Editable(false);
})
.Update(update => update.Action("UpdateProject", "Project").Data("serialize"))
.Destroy(update => update.Action("DeleteProject", "Project").Data("serialize"))))
in the tool bar I have dropdown list for doing filter on the group.
also I have drop down list filter on this column in the grid : columns.Bound(c => c.Name).Title("Name").Width(120).Filterable(f => f.UI("NamesProjectFilter").
this filter is for presenting name list for the projects.
I want that this drop down list will present only projects that belong to the selected product (in the group filter).
so i did like your example of cascading drop down list https://demos.telerik.com/aspnet-mvc/dropdownlist/cascadingdropdownlist:
this is the drop down list of the projects
var NamesProjectFilter = function (element) {
element.kendoDropDownList({
autoBind: false,
cascadeFrom: "ProjectsByProduct",
dataSource: {
type: "odata",
serverFiltering: true,
transport: {
read: "/Project/NamesProjectList"
}
},
valuePrimitive: false,
optionLabel: "Select a project..."
});
}
this is the function in the controller:
public ActionResult NamesProjectList([DataSourceRequest] DataSourceRequest request, int? ID)
{
List<string> projects;
if (ID != null)
{
projects = m_Repository.FindAllBy<TaskManagement.Data.Project>(p => p.ProductID == ID)
.OrderBy(x => x.Name)
.Select(x => x.Name).ToList();
}
else
{
projects = m_Repository.GetAll<TaskManagement.Data.Project>()
.OrderBy(x => x.Name)
.Select(x => x.Name).ToList();
}
return Json(projects, JsonRequestBehavior.AllowGet);
}
everything is working fine, the value of the selected product is sent in the network. but in the controller I always get null.
can someone help me please?
Thanks!
In the Editing example, (screenshot attached) if the user clicks on Add New Record, a new blank line appears at the top of the TreeList, therefore the new entry would be at the root. How would I go about it, if I wanted to add someone under Buffy (using the sample data)? I understand, I could have the user add a new row, then drag and drop the new value anywhere in the hierarchy, but I have a few issues with that. First, I don't think it's a great user experience for the user to have to do that. Secondly, and more importantly, we have business rules that don't allow people add a value to the root level.
I was hoping I could click on the row for Buffy, then click add and have the new row appear under Buffy's row. Is this possible?
Thanks,
Mike
Hello Telerik,
I'm having some trouble implementing the scenario I need (not a very complex one, indeed), which is the following.
I use the Policy class as Model, which contains a Contractor property, marked with [Required] attribute. The Contractor class contains the "Id" and "Name" properties. On the View, I need to add a DropDownList which loads and displays the available contractors list (only when the user opens it), stores the selected contractor, validates it (it is mandatory), and keeps it persistently stored also when refreshing the page (e.g. after a callback which notifies failed validations on the page).
On the View I added:
<td>
@(Html.Kendo ( ).DropDownListFor ( model => model.Contractor )
.DataTextField (
"Name"
)
.DataValueField (
"Id"
)
.HtmlAttributes (
new
{ style =
"width: 200px;"
, id =
"contractorComboBox"
} )
.AutoBind(
false
)
.DataSource ( source =>
{
source.Read ( read => read.Action (
"searchcustomers"
,
"customer"
) ).ServerFiltering (
true
);
} )
)
</td>
<td>
@Html.ValidationMessageFor(model => model.Contractor,
""
,
new
{ @
class
=
"text-danger"
})
</td>
The SearchCustomers method on the Customer controller simply retrieves a list of available Customer instances.
With this code, the list is correctly retrieved and bound, and also the validation appears. Unfortunately, when some data is selected in the dropdown, it is not posted on the Controller (the Contractor property is null). Furthermore, when the page is refreshed, also the error message "The value '3' is invalid" appears in the validation field.
Could you please give me a hand to understand what I am doing wrong?
Thank you
Hello,
How do we go about getting the checked items when we submit a form containing the DropDownTree? Specifically, I'd like to get a list of checked Id values from the TreeViewItemModel.
Thanks
I'm trying to set the destroy command visible. I need the button turn to visible or invisible using a condition(The condition depends on the selection from a DropDownList column). The first time that grid load the button shows perfectly, but when the grid changed the visible function doesn't work, the button do not turn to visible or invisible.
Is there any way that I can accomplish that? Thanks
This is my code:
columns.Command(command =>
{
command.Destroy().Visible("ButtonDestroyVisible");
});
function ButtonDestroyVisible(dataItem) {
return dataItem.Status.StatusId == 1; //Set to visible when StatusId == 1
}
Hello,
I have a rather straightforward question.. For example when I use Kendo UI HtmlHelper to create a radio button and label:
@Html.Kendo().RadioButton().Name("isNotUKResident").HtmlAttributes(new { @name = "IsUKResident" }).Label("No").Value("0")
The rendered HTML looks like this:
<input name="IsUKResident" class="k-radio valid" id="isNotUKResident_0" aria-invalid="true" type="radio" value="0">
<label class="k-radio-label" for="isNotUKResident_0">No</label>
I want to be able to add HTML attributes to the Label tag, such as class and style. Is this achievable with the Kendo UI HtmlHelper? If so, as an example, how should I modify the Razor code above to achieve that?
Thanks
Hello
I want to create a conversation between the admin in the panel and the users on the site
Please explain how to configure Chat widget in Asp.Net Mvc
Hi,
[b]I need to show a message after the creation of record using ajax callback. The text of message is made in mvc controlller.[/b]
My controler is simply:
[code] [HttpPost]
public ActionResult User_Create([DataSourceRequest] DataSourceRequest request, UserRoleModel model)
{
if (model != null && ModelState.IsValid)
try
{
new LoginCommand().CreateUserData(model, UserSession, ref myMessage);
}
catch (Exception exception)
{
ModelState.AddModelError("", exception.Message);
}
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
[/code]
The interface in razor looks like this
[code] @(Html.Kendo().Grid(Model).Name("UzytkownicyGrid")
.Columns(cols =>
{
cols.Bound(p => p.UserLogin).Width(150).Locked();
cols.Bound(p => p.UserName).Width(200);
// cols.Bound(p => p.Status).Width(60);
cols.Bound(p => p.Active).ClientTemplate("#=Active ? 'Tak': 'NIE'#").Width(80);
if (WlasneCommonFunc.IsAdministrator(ViewData))
{
cols.Command(command => command.Edit().Text("edytuj")).Width(120);
}
cols.Bound(p => p.MailAddress).Width(200).ClientTemplate("#= createMailLink(MailAddress) #");
cols.ForeignKey(p => p.RoleId, (IEnumerable)ViewData["roles"], "IdRoli", "Summary")
.Title("Uprawnienia").Width(150).MinScreenWidth(900);
cols.Bound(p => p.Mobilephone).Width(100).MinScreenWidth(1000).ClientTemplate("#= createPhoneLink(Mobilephone) #");
cols.Bound(p => p.Telephone).Width(100).MinScreenWidth(1100).ClientTemplate("#= createPhoneLink(Telephone) #");
cols.Bound(p => p.Funkcja).Width(100).MinScreenWidth(1200);
cols.Bound(p => p.MailDw).Width(200).MinScreenWidth(1300).ClientTemplate("#= createMailLink(MailDw) #");
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("UzytkownicyEdit").Window(w => w.Title("Korekta uprawnień").Width(400)))
.Groupable()
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.Sortable()
.Filterable()
.ToolBar(toolbar =>
{
if (WlasneCommonFunc.IsAdministrator(ViewData))
{
toolbar.Create();
}
})
.Navigatable()
.Events(e => e.Edit("uzytkownikEdit"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Model(model => model.Id(p => p.Identity))
.Events(events => events.Error("errorHandler"))
.Read("Uzytkownicy_Read", "Profil")
.Update("Uzytkownicy_Update", "Profil")
.Create("Uzytkownicy_Create", "Profil")
.Group(groups => groups.Add(p => p.RoleId))
))
[/code]
With displaying errors I have no problems.They are showed by the following function
[code]function errorHandler(e) {
if (e.status = "error") {
var message = "OPERACJA NIEUDANA\n";
if (e.errors) {
$.each(e.errors, function(key, value) {
if ('errors' in value) {
$.each(value.errors, function() {
message += this + "\n";
});
}
});
} else
message += e.errorThrown;
alert(message);
}
}
[/code]
What method is the best to do with it? Please help me out.
Regards,
Josef Jaskowiec
Rekord