Telerik Forums
UI for ASP.NET MVC Forum
2 answers
122 views
Hi there, it's my first time trying to do a search result binding using ASP.NET MVC + ListView. I have included the source codes below. Please let me know if there is anything I should modify, and what I need to do to get it to work.

1. Search Form
01.<div class="content-wrapper">
02.    <div class="search-wrapper">
03.        @using (Html.BeginForm("Search", "Home", FormMethod.Post, new { id="search-form" }))
04.        {
05.            <div class="search-top-panel">
06.                <input id="tbKeywords" name="tbKeywords" type="text"
07.                       class="k-textbox" style="width: 600px; font-size: 24px;"
08.                       required validationmessage="Enter a keyword"
09.                       placeholder="Enter a Keyword" />
10.            </div>
11.            <div class="search-bottom-panel">
12.                <div class="search-bottom-left-panel">
13.                    @Html.ActionLink("Advance Search Options", "Index", "Home", new { search="adv" }, new { @class="standard-link" } )
14.                </div>
15.                <div class="search-bottom-right-panel">
16.                    @(Html.Kendo().Button().Name("btnSearch").Content("Hit It!").HtmlAttributes(new { type = "submit", @class = "k-primary" }))
17.                </div>
18.            </div>
19.        }
20.    </div>
21.</div>

2. Backend Code
01.[HttpPost]
02.public ActionResult Search()
03.{
04.    ViewBag.Keywords = Request.Form [ "tbKeywords" ];
05. 
06.    VideoRepository videoRepository = new VideoRepository ( );
07. 
08.    List<string> keywords = new List<string> ( );
09. 
10.    keywords = Request.Form [ "tbKeywords" ].Split ( new char [ ] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries ).ToList ( );
11. 
12.    IList<Video> lstResults = new List<Video>();
13. 
14.    IList<Video> videos;
15.     
16.    foreach(string keyword in keywords)
17.    {
18.        videos = videoRepository.GetAll ( ).Where ( v => v.VIDEO_TITLE.Contains ( keyword ) || v.VIDEO_DESC.Contains ( keyword ) ).ToList ( );
19. 
20.        foreach(Video v in videos)
21.        {
22.            if ( !lstResults.Contains ( v ) )
23.                lstResults.Add ( v );
24.        }
25.    }
26. 
27.    ViewBag.Results = lstResults;
28. 
29.    return RedirectToAction ( "Index", new { view = "results" } );
30.}

3. ListView
01.@if (Request.QueryString["view"] == "results")
02.{
03.    <div class="ui-memberVideolist" style="width: 100%;">
04.        @(Html.Kendo().ListView<TheWebDevChannel.Models.VideoManagement.Video>(ViewBag.Results)
05.            .Name("lvMemberVideoList")
06.            .TagName("div")
07.            .ClientTemplateId("template")
08.            .Pageable()
09.        )
10.    </div>
11.}

I do recognize that my list view is incomplete code, because I am not exactly sure what else is required.
Sherman
Top achievements
Rank 2
 answered on 13 Dec 2014
3 answers
376 views
I have a grid defined as:-
@(Html.Kendo().Grid<WT_Portal_PMS2.Models.ClockStopsSummary>()
    .Name("StopGrid")
    .Columns(col =>
        {
            col.Bound(o => o.CurrentWaitingBand).Title("Weeks Waited").ClientFooterTemplate("Total");
            col.Bound(o => o.DNA).Title("DNA").ClientFooterTemplate("#= sum  #"); ;
            col.Bound(o => o.IP).Title("Admitted").ClientFooterTemplate("#= sum  #"); ;
            col.Bound(o => o.OP).Title("Non-Admitted").ClientFooterTemplate("#= sum  #"); ;
 
 
        })
       .ToolBar(tools => tools.Excel())
                   .Excel(excel => excel
                                    .FileName("ClockStopsSummary.xlsx")
                                    .Filterable(true)
                                    .AllPages(true)
                                    .ProxyURL(Url.Action("Excel_Export_Save", "IPWLDQ"))
                                    )
              
 
        .DataSource(ds => ds
        .Ajax()
                .Aggregates(ag =>
                {
                    ag.Add(p => p.DNA).Sum();
                    ag.Add(p => p.IP).Sum();
                    ag.Add(p => p.OP).Sum();
                })
        .PageSize(25)
                        .Model(m => m.Id(p => p.CurrentWaitingBand))
                  .Read(rd => rd.Action("_Table", "StopsAnalysis")
                       .Data("specFilter")
 
        )
        )
                
        .Sortable()
 
)


When I try to export the grid to Excel, a javascript error in kendo.all.min.js of 'Unhandled exception at line 578, column 7 in Function code0x800a138f - JavaScript runtime error: Object expected' is thrown.

If I remove the aggregate expressions, the export runs without a problem.  I see the demo example uses aggregates, but can't see any obvious differences. 
John
Top achievements
Rank 1
 answered on 12 Dec 2014
1 answer
1.2K+ views
I am trying to alter the meber name of a filterdescriptor but get error Unable to cast object of type 'Kendo.Mvc.CompositeFilterDescriptor' to type 'Kendo.Mvc.FilterDescriptor'  here

If request.Filters.Any(Function(y) CType(y, Kendo.Mvc.FilterDescriptor).Member.Equals("FranchiseeName")) Then
 
                     Dim filter As FilterDescriptor = CType(request.Filters.Single(Function(g) CType(g, Kendo.Mvc.FilterDescriptor).Member.Equals("FranchiseeName")), FilterDescriptor)
                     filter.Member = "Franchisee.Name"
 
 
                 End If

I don't know what the difference is or why I get this, I have done simular before without this problem.
Thanks

​
Rosen
Telerik team
 answered on 12 Dec 2014
2 answers
866 views
I have the grid defined below.  I need to be able to edit the Flag Notes column and post it back.  I have so far come up with 2 solutions that are close but don't quite fit the bill.  

#1 gives a textarea to edit in, and it works exactly how it should, except the textarea is always visible and not just when you click in the cell to edit it.  
#2 also works, it hides the text box until you click in it, and it will save the text entered.  The problem comes when double quotes are entered into the field.  then the text that is saved ends with the 'closing' ".  How do I get it to accept both single and double quotes?

#2 is really what we want with the added bonus of actually being able to save double quotes or at least prevent them, maybe replace them with singles

<div id="divSearchResults">
     
       @(Html.Kendo().Grid((IQueryable<CallListModel>)Model)
       .Name("grid")
       .Editable(ed => ed.Mode(GridEditMode.InCell))
       .Pageable()
       .Sortable()
       .Scrollable(a => a.Height("auto"))
       .Filterable()
       .DataSource(ds => ds.Ajax()
           .PageSize(Constants.MaxSearchReults)
           .Sort(sort => sort.Add("Name").Ascending())
           .ServerOperation(false)
           .Update(update => update.Action("SaveFlagComments", "Reports"))
           .Model(mod =>
               {
                   mod.Id(m => m.ID);
                   mod.Field(p => p.Zone).Editable(false);
                   mod.Field(p => p.Name).Editable(false);
                   mod.Field(p => p.CarrierCode).Editable(false);
                   mod.Field(p => p.Location).Editable(false);
                   mod.Field(p => p.DispatchPhone).Editable(false);
                   mod.Field(p => p.DispatchFax).Editable(false);
                   mod.Field(p => p.DispatchEmail).Editable(false);
               }))
       .Columns(columns =>
       {
          columns.Template(@<text></text>)
                   .ClientTemplate("<input type='checkbox' " + ViewBag.disable + 
                   "#= Contacted ? checked='checked':'' # class='chkbx' value='#= ID#' name='selectCarrier' />" +
                   "<input type='hidden' value='#= ID#' name='allCarriers' />")
                   .Width(25);
           columns.Bound(p => p.Zone).Filterable(false).Width(70);
           columns.Bound(p => p.Name).Filterable(false).Width(75);
           columns.Bound(p => p.CarrierCode).Filterable(false).Width(65);
           columns.Bound(p => p.Location).Filterable(false).Width(80);
           columns.Bound(p => p.DispatchPhone).Filterable(false).Width(70);
           columns.Bound(p => p.DispatchFax).Filterable(false).Width(70);
           columns.Bound(p => p.DispatchEmail).Filterable(false).Width(90);
           columns.Template(@<text></text>)
               .ClientTemplate(" <a href='" + Url.Action("Edit", "CarrierView", new { ID = "#=ID#" }) + "', target = '_blank' >Edit</a>").Width(30);
           columns.Bound(p => p.FlagNotes)
 #1              //.ClientTemplate("<textarea name='FlagNotes_#= ID#' cols='60' rows='3' style='height=100px'>#=FlagNotes#</textarea>")
 #2              .ClientTemplate("#=FlagNotes#<input type='hidden' name='FlagNotes_#= ID#' value=\"#=FlagNotes#\">")
               .Filterable(false).Width(120);
          // columns.Command(command => { command.Edit();}).Width(40);
       })
       )

   </div>
Paul Grothe
Top achievements
Rank 1
 answered on 11 Dec 2014
1 answer
108 views
Buenas Tardes amigos del foro disculpen por escribir en español, pero necesito ayuda de como crear un TreeView a partir de una consulta LinqToXML. Si me pueden facilitar un ejemplo en Visual Basic, estaría muy agradecido.
Daniel
Telerik team
 answered on 11 Dec 2014
1 answer
116 views
Hi there,
I've a Scheduler and a Grid, i want to update the schedule when someone create or update the items in the grid.

I've subscribed the sync event with: .Events(events => events.Sync("sync"))

then I update the scheduler:

 function sync(args) {
        $("#scheduler").data("kendoScheduler").dataSource.read();
        $("#scheduler").data("kendoScheduler").refresh();
}

it works, but if there is a server validation error the editor popup quits and the user can't see the validation error.
How can I detect a successfully update?

Server validation is implemented as in the example provided:

<script type="text/kendo-template" id="message">
    <div class="k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error"
         style="margin: 0.5em; display: block; " data-for="#=field#" data-valmsg-for="#=field#" id="#=field#_validationMessage">
        <span class="k-icon k-warning"> </span>#=message#<div class="k-callout k-callout-n"></div>
    </div>
</script>


<script type="text/javascript">
    var validationMessageTmpl = kendo.template($("#message").html());

    function error(args) {
        if (args.errors) {
            var grid = $("#grid").data("kendoGrid");
            grid.one("dataBinding", function (e) {
                e.preventDefault();   // cancel grid rebind if error occurs

                for (var error in args.errors) {
                    alert(args.errors[error].errors);
                    showMessage(grid.editable.element, error, args.errors[error].errors);
                }
            });
        }
    }

    function showMessage(container, name, errors) {
        //add the validation message to the form
        container.find("[data-valmsg-for=" + name + "],[data-val-msg-for=" + name + "]")
                 .replaceWith(validationMessageTmpl({ field: name, message: errors[0] }))
    }

</script>



Daniel
Telerik team
 answered on 11 Dec 2014
1 answer
316 views
This is driving me crazy... I want to do some formatting on the cell that is housing the .k-event after the databound event is triggered.  However, it's triggered 3 times every time the page is loaded or I navigate to a new time.  Any idea why this is happening?

Rosen
Telerik team
 answered on 10 Dec 2014
1 answer
154 views
when I make a treelist as grid detail template  and click the create button 
I got  an error like   TypeError: parent is undefined  kendo.all.js--line:103021
any way to solve it?

Thanks!
Nikolay Rusev
Telerik team
 answered on 10 Dec 2014
1 answer
222 views
I've got a chart defined as:-

@(Html.Kendo().Chart<WT_Portal_PMS2.Models.OpenClockSummary>()
       .Name("chart")
       .Title("Open Clocks by Weeks Waiting")
       .Theme("bootstrap")
       .Legend(legend => legend
           .Position(ChartLegendPosition.Top)
           .Visible(false)
       )
                   .DataSource(ds => ds.Read(read => read.Action("_BarChartp", "Summary")
                              .Data("specFilter")
 
                   ))
       .Series(series =>
       {
           series.Column(model => model.Clocks, model => model.barColour);
 
 
 
       })
       .ChartArea(area => area
           .Height(350)
           .Background("transparent"))
       .CategoryAxis(axis => axis
           .Categories(model => model.CurrentWaitingBand)
           .Labels(labels => labels.Rotation(-90))
           .MajorGridLines(lines => lines.Visible(false))
       )
       .ValueAxis(axis => axis.Numeric()
           .Labels(labels => labels.Format("{0:N0}"))
           .Line(line => line.Visible(false))
       )
       .Tooltip(tooltip => tooltip
           .Visible(true)
           .Format("{0:N0}")
       )
 
                   )

What I need to do is add a boostrap badge to the chart title, so each one of the charts has an easily idfentifiable reference number.
E.g:-
<span>Open Clocks by Weeks Waiting</span>  <span class="pull-right badge">C1</span>

How can I put this markup into the title? Any attempt to add spans etc., result in javascript errors when the page is run.

Thanks
T. Tsonev
Telerik team
 answered on 10 Dec 2014
1 answer
679 views
Hello,

I am displaying  popup window from parent displaying a  partial view. When the partial view loads my parent window URL is already changing to Controller/Action for partialview. When i submit the partial view i do not want to refresh the parents window. Submitting partial view should just Close Pop up  window. How can i achieve this. parent window method to Show popup window code is like this
var direction = "ObjectDetail/Index";
var wnd = $("#ObjectDetail").data("kendoWindow");
if (wnd) {
wnd.refresh({
url: direction,
data: { id: item.id }

});
wnd.element.css("visibility", "");
wnd.center();
wnd.open();
}
At this Point when child window Pops up parent window URL is changing to this new URL.

The partial view has beginform
@using (Html.BeginForm("SubmitFormCollection", "ObjectDetail"))
{
and on submit the actionresult i have to Redirect to parent URL again and this refreshes parent view
      [AcceptVerbs(HttpVerbs.Post)]
         public ActionResult SubmitFormCollection(ControlsContext selModel, FormCollection formCollection)
         {
   //do something
              return RedirectToAction("Index", "ObjektActivity");         }

How can i submit the popup window and Close it without refreshing parent.

Anamika
Anamika
Top achievements
Rank 1
 answered on 09 Dec 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?