Telerik Forums
UI for ASP.NET MVC Forum
1 answer
166 views
I am trying to implement search criteria which bind to Kendo Ui grid.
However it return no record and no error display. Is there something i
missed?

Controller code :

[HttpPost]
public ActionResult SearchProduct(ProductSearchCriteria criteria)
{
string nameCriteria = string.Empty;
string descCriteria = string.Empty;

TTSEntities dc = new TTSEntities();
if (!string.IsNullOrWhiteSpace(criteria.Name)) nameCriteria = criteria.Name.ToLower().Trim();

if (!string.IsNullOrWhiteSpace(criteria.Community)) descCriteria = criteria.Desc.ToLower().Trim();

var results = dc.Products.AsQueryable();
if (criteria.Name!= null)
results = results.Where(b => b.Name== criteria.Name);

if (criteria.Desc!= null)
results = results.Where(b => b.Desc== criteria.Desc);


return PartialView("_ProductGrid", results.ToList());
}



Index.cshtml


@model HHIMS_Web_App.Models.ProductSearchCriteria

@using (Html.BeginForm())
{
<div id="headerpanel">
<fieldset>
<legend style="font-size:14px">Search Criteria</legend>
<div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)

</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
</div>

</div>
<div>
<div class="editor-label">
@Html.LabelFor(model => model.Desc)

</div>

<div class="editor-field">
@Html.EditorFor(model => model.Desc)
</div>

<div class="smallBox">

<input type="button" value="Search" id="btnProductSearch" style="height:33px; font-size:14px; background-color:#3399FF" class="k-button" />

</div>
</div>
</fieldset>

</div>
}




<script type="text/javascript">

$(document).ready(function () {

$('#btnProductSearch').click(function (e) {
var searchParameters = GetSearchParameters();
var jsonData = JSON.stringify(searchParameters, null, 2);

$.ajax({
url: '@Url.Content("~/ProductDetails/SearchProduct/")',
type: 'POST',
data: jsonData,
datatype: 'html',
contentType: 'application/json; charset=utf-8',
success: function (data) {
$('#btnProductSearch').replaceWith(data);
},
error: function (request, status, err) {
alert(status);
alert(err);
}
});

});


function GetSearchParameters() {
var hrn = $("#Name").val();
var community = $("#Desc").val();


return { Name: name,
Desc: desc

};
}



});

</script>

_ProductGrid.cshtml

<div>
<fieldset class="searchResults">
<legend style="font-size:14px">Search Result</legend>
<br />
<div>
@(Html.Kendo().Grid<TTP.Models.ProductModel>()

.Name("Product")
.HtmlAttributes(new { @Style = "align:center; font-size:10px; width:500px" })
.Columns(columns =>
{

columns.Bound(p => p.Name);
columns.Bound(p => p.Desc);

})
.AutoBind(false)
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable()
//.Pageable()
.Pageable(paging => paging
.Input(false)
.Numeric(true)

.PreviousNext(true)
.PageSizes(new int[] { 5, 10, 25, 50 })
.Refresh(false)

)
.Selectable()
.Scrollable()
.ColumnMenu(c => c.Columns(false))
.DataSource(dataSource => dataSource
.Ajax()//bind with Ajax instead server bind
.PageSize(10)
.ServerOperation(true)
.Model(model =>
{
model.Id(p => p.Name);

})




)
)

</div>
</fieldset>
</div>
Petur Subev
Telerik team
 answered on 17 Apr 2013
1 answer
107 views
I have a custom edit pop-up.  I'm trying to add a hidden byte array, but it's not working.  They byte array will be dynamic but I can't even get a hard coded version to work properly.

If I put the following line in the custom edit cshtml file,
<input id="RowVersion" name="RowVersion" type="hidden" value="AAAAAAAAZZM=">
The pop-up renders it as:
<input id="RowVersion" name="RowVersion" type="hidden" value="[object Object]" data-bind="value:RowVersion">
When I try it in a regular MVC page everything works as expected.  (Also, this is the only part of the model that doesn't render correctly in the custom edit pop-up.)
Atanas Korchev
Telerik team
 answered on 17 Apr 2013
1 answer
108 views
I want to know how I have somthing like this
http://www.aspnetwiki.com/page:kendoui-ext-api-dropdowngrid
in kendo.mvc?
Dimo
Telerik team
 answered on 17 Apr 2013
1 answer
102 views
I am trying to implement an Autocomplete on a partial view.  The model contains the data in a property called AvailableMatters which is an IEnumerable<Matter>.  Matter has a property called "Name" which is what I want to display and have users type in the autocomplete box.

Looking at the html that is being rendered, it's got my data in the autocomplete widget.  However, nothing happens when you type in the autocomplete box. 
This is the html that is being rendered:
 <input id="activeMatterID" name="activeMatterID" type="text" />
<script>
    jQuery(function(){jQuery("#activeMatterID").kendoAutoComplete({"select":activeMatterIDSelected,"change":activeMatterIDChanged,
"dataSource":[{"MatterID":10259,"IsMasterDataset":false,"IsChildMatter":false,"ParentMatterID":0,"ParentMatterName":null,"Name":"01_Automated Test Matter","ClientID":3089,"ClientName":"01_AutomatedTestClient","SubClientID":0,"SubClientName":null,"Description":"","ServerID":1,"DatabaseName":"20_10259_3089_Matter_100062_22Jan13_052007","JobNumber":0,"Status":1,"StatusDisplay":1,"Priority":2,"EstimatedJobSizeInGb":0,"ArchiveLocation":null,"DBSchemaVersion":"5.0.0.0","AccountManagerID":21,"AccountManagerName":"Bob Jones","ClientMatterPO":"Matter Test","ContactName":"","ContactPhone":"","ProjectPath":null,"DisplayProjectPath":"","BackupNotes":null,"CurrentLoadVersion":null,"CreatedBy":67,"CreatedDate":"\/Date(1358896807610)\/","ModifiedBy":67,"LastModifiedDate":"\/Date(1358896807610)\/","LastAccessedDate":"\/Date(-62135575200000)\/","LastBackupDate":"\/Date(-62135575200000)\/","TimeZoneName":null},{"MatterID":10263,"IsMasterDataset":false,"IsChildMatter":false,"ParentMatterID":0,"ParentMatterName":null,"Name":"01_AutomatedTestMatter2","ClientID":3089,"ClientName":"01_AutomatedTestClient","SubClientID":0,"SubClientName":null,"Description":"","ServerID":1,"DatabaseName":"20_10263_3089_Matter_23Jan13_023035","JobNumber":0,"Status":1,"StatusDisplay":1,"Priority":2,"EstimatedJobSizeInGb":0,"ArchiveLocation":null,"DBSchemaVersion":"5.0.0.0","AccountManagerID":21,"AccountManagerName":"Bob Jones","ClientMatterPO":"987654","ContactName":"","ContactPhone":"","ProjectPath":null,"DisplayProjectPath":"","BackupNotes":null,"CurrentLoadVersion":null,"CreatedBy":67,"CreatedDate":"\/Date(1358973035963)\/","ModifiedBy":67,"LastModifiedDate":"\/Date(1358973035963)\/","LastAccessedDate":"\/Date(-62135575200000)\/","LastBackupDate":"\/Date(-62135575200000)\/","TimeZoneName":null},],
"dataTextField":"Name",
"placeholder":"Search..."});});
</script>

In Firebug if I look at the HTML view it actually shows me stuff I can't see from the page source, presumably digging down into the Kendo script somewhere:
<span class="k-widget k-autocomplete k-header k-state-default" tabindex="-1" role="presentation" style=""><input id="activeMatterID" class="k-input" type="text" name="activeMatterID" data-role="autocomplete" placeholder="Search..." style="width: 100%;" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-readonly="false" aria-owns="activeMatterID_listbox" aria-autocomplete="list"><span class="k-icon k-loading" style="display:none"></span></span>

Why does autocomplete="off"?  I don't see anywhere in the helper where I can explicitly turn this on?

And this is the helper code, which was derived from your documentation.
 @(Html.Kendo().AutoComplete()
          .Name("activeMatterID") //The name of the autocomplete is mandatory. It specifies the "id" attribute of the widget.
          .DataTextField("Name") //Specifies which property of the Matter to be used by the autocomplete.
          .BindTo(Model.AvailableMatters)   //Pass the list of Matters to the autocomplete.
          .Events(e => e.Select("activeMatterIDSelected").Change("activeMatterIDChanged"))
          .Placeholder("Search...")
          )

On screen it just looks like a blank textbox.  I do not even see the placeholder text.  I have the latest version  of these Kendo UI Complete plus MVC, I only downloaded it yesterday.

The change event does fire, the value is whatever got typed into the box (which generally isn't valid because no autocomplete occurred and users aren't going to know the exact name type type in.

We are not using any Telerik data sources, we have a custom WCF service we use to retrieve data so we do not want the autocomplete to bind to anything other than the data we pass in via the model.  I want to just capture the select & change events to call our own methods to act based on what they select.

So..what do I need to do to get the autocomplete to function (i.e. to autocomplete when a user types)?

As a second question, ideally I would like to capture not the text that they type but another field on the object associated with their selection.  The objects are Matters, we are showing the Matter.Name, but I would like to retrieve the Matter.MatterID and use this to act off of instead of the Matter.Name.  Is this possible, and how would I do this?  I can work off name if necessary but it's sub-ideal.  My main concern at the moment is getting the autocomplete to work.

Thanks in advance!
Robert
Top achievements
Rank 1
 answered on 16 Apr 2013
0 answers
111 views
Please help with rendering a byte array.
Jeremy
Top achievements
Rank 1
 asked on 16 Apr 2013
0 answers
101 views
Good morning,

I'm having the same issue seen here:
http://www.kendoui.com/forums/permalink/4pdb6wyQTUWsacYhmciO0w. (I've
also seen a few other posts about this same issue)

Unfortunately I don't understand the answer.  Could someone please provide a little more detail about what the answer means?

Thanks!
Jeremy
Top achievements
Rank 1
 asked on 16 Apr 2013
1 answer
439 views
Hello,
There seem to be several examples dotted around the place on how to handle Model State errors
e.g. How do I display model state errors?
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq
However I cannot find any documentation on how to create the error on the server in the first place.
Any hint of what needs to replace the comments shown below, would be much appreciated.
Regards,
Pete
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update_User([DataSourceRequest] DataSourceRequest request, UserProfile userprofile)
{
  if (userprofile != null && ModelState.IsValid)
  {
    if (errorcondition)
    {
      //raise something here that will be picked up by the onError function described above
      //to inform the user that some sort or error occured
    }
  }
  else
  {
    //raise something here that will be picked up by the onError function described above
    //to inform the user that the ModelState.IsValid is Invalid
  }
  return Json(ModelState.ToDataSourceResult());
}


Vladimir Iliev
Telerik team
 answered on 16 Apr 2013
1 answer
128 views
Grid values do not seem to use the DisplayTemplate as defined.  Is there something to do to get them to use them?

I suppose as an alternative I could use the ClientRowTemplate and do it that way, but seems over kill.
Dimiter Madjarov
Telerik team
 answered on 16 Apr 2013
2 answers
291 views
Hello!
I want  editing as here  http://www.kendoui.com/code-library/mvc/grid/using-multiselect-in-grid.aspx and 

I have Model:
public class ShrinkCoeffModel
    {
        [Display(Name = "thickness")]
        public virtual int Thickness { get; set; }
           
        [Display(Name = "wett")]
        public virtual string[] Wetness { get; set; }
   
        [Display(Name = "coeff")]
        public virtual decimal[] Coeff { get; set; }
    }
and Grid: (1.png)
@(
 Html.Kendo().Grid(Model)
                .Name("ShrinkCoeff")
                .ToolBar(commands =>
                {
                    commands.Create();
                })
                .Columns(columns =>
                {
                    columns.Bound(o => o.Thickness);
                    for (int i = 0; i < Model.FirstOrDefault().Wetness.Count(); i++)
                    {
                    columns.Bound(o => o.Wetness[i]);
                           
                    }
                    columns.Command(command =>
                    {
                        command.Edit();
                        command.Destroy();
                    }).Width(210).Title("Действия");
                })
                .Editable(editable => editable.TemplateName("Item").Mode(GridEditMode.PopUp))
                .DataSource(dataBinding => dataBinding
                    .Server()
                                                    .Model(model => model.Id(o => o.Thickness))
                                                        .Update("Edit", "ShrinkCoeff")
                                                        .Create("Create", "ShrinkCoeff")
                                                        .Destroy("Delete", "ShrinkCoeff"))
                .Pageable()
                .Sortable()
                .Selectable()
)
And if I click Edit I see this: 2.png 

But I want :

first Wetness             first Coeff                                                     
second Wetness      second Coeff  
.....                                  ......

how to display  also to and edit
how I can this do?

(I can pass my model to EditorTemplates and use:
@foreach(Type item in Model)
{
......) 
There are other ways?)
Gusev
Top achievements
Rank 1
 answered on 15 Apr 2013
1 answer
127 views
I want use text box in form or grid that user can only select value from special list for this action I want show button inside textbox and user click on this button an show list on data and after select special record the value of select record show on text box and popup window close.
Saeid
Top achievements
Rank 1
 answered on 15 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?