Telerik Forums
Kendo UI for jQuery Forum
2 answers
134 views

Lets say I have a ViewModel (pseudo code):

MyViewModel​: ObservableObject {

    myItems: ObservableArray<MyItemViewModel> 
}

MyItemViewModel: ObservableObject {

    myFunction: function() {

        // Some code here...

    }

}

Then, if I make an instance of MyViewModel the dataSource of Kendo Grid, what would the syntax for mapping each row's custom command to myFunction be? I can (as in examples) map to inline function that will then find nearest tr and it's dataItem, then call the function - but I would rather like it (if possible) to map it directly to the function of each row's ViewModel... Any ideas?

 

Thanks in advance.

Bojan
Top achievements
Rank 1
 answered on 14 Aug 2015
1 answer
282 views

I am trying to use the ListView edit mode with AngularJS.  In the code snippet below, everything works with the exception of Cancel.  Add, Edit, Delete, and Update are all fine.  Cancel, however does not.  When you hit cancel it accepts the current value in the edit box rather than revering it back to what it was before the edit.

 

<div kendo-list-view="urlList" k-data-source="dataItem.OsmParams" k-on-save="urlList.refresh()"
     k-editable="true" style="height:300px; width:100%; min-width:490px;">
    <div k-template style="display:flex; flex-direction: row; align-items:center; margin:5px;">
        <div style="display:inline-block;width:410px;word-wrap: break-word">{{ dataItem.Url }}</div>
        <a class="k-button k-button-icontext k-edit-button kendo-command-notext"><span class="k-icon k-edit"></span></a>
        <a class="k-button k-button-icontext k-delete-button kendo-command-notext"><span class="k-icon k-delete"></span></a>
    </div>
    <div k-edit-template style="display:flex; flex-direction: row; align-items:center; margin:5px;">
    <input style="width:410px;" type="text" class="k-textbox" name="Url" required="required" validationMessage="required" />
    <a class="k-button k-button-icontext k-update-button kendo-command-notext"><span class="k-icon k-update"></span></a>
    <a class="k-button k-button-icontext k-cancel-button kendo-command-notext"><span class="k-icon k-cancel"></span></a>
    </div>
</div>
<div style="width:100%; text-align: center">
    <a style="margin-top: 5px;" class="k-button k-button-icontext k-add-button" ng-click="urlList.add()"><span class="k-icon k-add"></span>Add URL</a>
</div>

Rosen
Telerik team
 answered on 14 Aug 2015
1 answer
199 views
How would I setup a map to handle double clicks? I want to allow users to recenter/zoom on double-click.
Iliana Dyankova
Telerik team
 answered on 14 Aug 2015
3 answers
644 views

This is a strange problem. I have a grid (code below) that contains a templated column for a drop-down control.  Whenever I run the site via an ip address I get the error.  However, when I access the site with a proper domain (eg, rep.ngkflocal.com), it functions fine. 

For instance, when accessed via the following URL: http://72.73.307.275/Plan/Edit/1342
The following error occurs: Uncaught ReferenceError: CapitalExpenditureType is not defined 

However, when accessed like this via my local IIS web app: http://reppublish.ngkflocal.com/Plan/Edit/1342
I do not get the error, adding the row works fine. 

Both point to the same files. Any ideas? 

My Grid code follows: 

  @(Html.Kendo().Grid<Rep.Models.CapitalExpenditureViewModel>()

                                      .Name("CEGrid")
                                      .Columns(columns =>
                                      {
                                          columns.Bound(c => c.Description);
                                          columns.Bound(c => c.CapitalExpenditureType).ClientTemplate("#=CapitalExpenditureType.Value#").Width(250);
                                          columns.Bound(c => c.Amount);
                                          columns.Bound(c => c.DateCostEstimated).Format("{0:dd/MM/yyyy}");
                                          columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
                                      })
                                      .HtmlAttributes(new { style = "height: 400px;" })
                                      .ToolBar(toolbar => toolbar.Create())
                                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                                      .Sortable()
                                      .Scrollable()
                                      .Resizable(resize => resize.Columns(true))
                                      .Pageable(pageable => pageable
                                          .Refresh(true)
                                          .PageSizes(true)
                                          .ButtonCount(5))
                                      .DataSource(datasource => datasource
                                          .Ajax()
                                          .Model(model =>
                                          {
                                              model.Id(p => p.CapitalExpenditureId);
                                              model.Field(p => p.CapitalExpenditureType).DefaultValue(
                                                  ViewData["defaultcapitalExpenditure"] as Rep.Common.LookupItem);
                                          })
                                          .Create(update => update.Action("CapitalExpenditures_Create", "Plan", new { Id = Model.PlanId }))
                                          .Read(read => read.Action("CapitalExpenditures_Read", "Plan", new { PlanId = Model.PlanId }))
                                          .Update(update => update.Action("CapitalExpenditures_Update", "Plan"))
                                          .Destroy(update => update.Action("CapitalExpenditures_Delete", "Plan"))
                                          .PageSize(50)
                                      )
                                      )
Kryszal
Top achievements
Rank 1
 answered on 14 Aug 2015
1 answer
229 views

Hi, I am trying to create a cascading MultiSelect, but I can't seem to get it right.

I have the following two multiselects and the piece of javascript that refreshes the data. I get the value of #MultiSelect1, but it never passes through to the Action2 Json method, the parameter  is ALWAYS null?

 

<div class="col-lg-2">
    <label>Multi1</label>
</div>
<div class="col-lg-10">
    @(Html.Kendo().MultiSelectFor(m => m.MultiSelect1)
        .DataSource(s => { s.Read(r => { r.Action("Action1", "Report"); }).ServerFiltering(true); })
        .DataTextField("Name")
        .DataValueField("Id")
        .HtmlAttributes(new { style = "width:300px" })
        .Events(evt => {evt.Change("onChange"); })
    )                           
</div>
                
<div class="col-lg-2">
    <label>Multi2</label>
</div>
<div class="col-lg-10">
    @(Html.Kendo().MultiSelectFor(m => m.MultiSelect2)
        .DataSource(s => { s.Read(r => { r.Action("Action2", "Report").Data("getList"); }).ServerFiltering(true); })
        .DataTextField("Name")
        .DataValueField("Id")
        .AutoBind(false)
        .HtmlAttributes(new { style = "width:300px" })
    )
</div>
 
<script type="text/javascript">
    function getList()
    {
        var list = $("#MultiSelect1").val();
 
        return {
            idList:list
        }
    }
</script>

Controller:

public JsonResult Action2(List<string> idList)
{
    .    
}

What am I missing? I have tried playing around with the object type of idList string[] etc.

 Thank you.

Daniel
Telerik team
 answered on 14 Aug 2015
2 answers
1.5K+ views

Hello. I am trying to bind a an object with an array of objects to a kendo.data.DataSource. The array of objects will be for a dropdownlist and everything else outside of the array will be for other fields on the form. Is there a way to do this? I know that if I just had an array of objects I could easily bind the dropdownlist to that DataSource, but is it possible to do it with an object with a list (array) of objects? Below is my code.

 

HTML MARKUP

<input data-role='dropdownlist'
    data-option-label='-- Select One --'
data-auto-bind='true' data-text-field='ServingPeriod' data-value-field='AdmServingPeriodId' data-primitive-value='true' data-bind='value: SelectedItem, source: DailyEntries' />

Petyo
Telerik team
 answered on 14 Aug 2015
7 answers
1.6K+ views
Hi there,

I'm trying to setup some custom filter types on my grid (using server filtering) to show only Blank or Non-blank rows.  Add add the custom filters to the columns and see my new items in the dropdown.  So far so good.  However, when I select either of those and then don't type anything in the text boxes the FilterMenu's _merge() function removes them from the filter as there is no value in the text box.  Is there any way I can currently get around this without modifying the _merge() to not remove filters with my new types if the filter text is empty?  Or is there any other way to accomplish this type of filter?

Thanks,
Matt

Here's my current column filterable setup in case it helps:
{
    extra: true,
    operators: {
        string: {
            eq: "Is equal to",
            neq: "Is not equal to",
            startswith: "Starts with",
            contains: "Contains",
            endswith: "Ends with",
            blank:"Is blank",
            notblank:"Is not blank"
        },
        number: {
            eq: "Is equal to",
            neq: "Is not equal to",
            gte: "Is greater than or equal to",
            gt: "Is greater than",
            lte: "Is less than or equal to",
            lt: "Is less than",
            blank:"Is blank",
            notblank:"Is not blank"
        },
        date: {
            eq: "Is equal to",
            neq: "Is not equal to",
            gte: "Is after or equal to",
            gt: "Is after",
            lte: "Is before or equal to",
            lt: "Is before",
            blank: "Is blank",
            notblank: "Is not blank"
        }
    }
}
Alexander Valchev
Telerik team
 answered on 14 Aug 2015
1 answer
510 views

Hi, I have a grid that I recently upgraded from old Telerik MVC Extensions.

before, the user could select, copy and paste to excel and the styles were keep in Excel.

 Now, I'm adding a button to Export to Excel, but styling is not exported.

 Is there a way to do that?

 

@(Html.Kendo().Grid<ShowNumber>().Name("GridNumber")
.ToolBar(bar => bar.Excel().Text(Shared.buttonExportExcel))

.DataSource(ds => ds.Ajax().Read(read => read.Action("ReadNumber", "QueryNumbers").Data("getFilter")) ​

.Columns(columns =>{
columns.Bound(c => c.Description);
columns.Bound(c => c.Initial);
columns.Bound(c => c.Final);
})
.Events(ev => ev.DataBound("volumeDataBound")))

and this is my javascript for changing styles:

function volumeDataBound(e)
{
    var grid = this;
    var currentRecords = grid.dataSource.view();
 
    for (var i = 0; i < currentRecords.length; i++) {
        //currentRecords[i] is the current dataItem
        var item = currentRecords[i];
        if(item.DataCorrida==null || item.DataCorrida == '') {
            var tr = grid.tbody.find("[data-uid='" + item.uid + "']");
            tr.find("td.k-hierarchy-cell .k-icon").removeClass();
        }
        if (item.IsShipped) {
            grid.tbody.find("tr[data-uid='" + item.uid + "']").addClass("shipped-row");
        }
        else if(item.IsRemoved){
            grid.tbody.find("tr[data-uid='" + item.uid + "']").addClass("removed-row");
        }
        else{
            grid.tbody.find("tr[data-uid='" + item.uid + "']").addClass("regular-row");
        }
    }
}

Also, I'm not sure if this is the best way to change styles.

Dimiter Madjarov
Telerik team
 answered on 14 Aug 2015
5 answers
1.5K+ views

Hello ,

What is the best practice to attach event handler on the column header of Grid.
I have found following way.
$("th[role='columnheader']"), function () {
    // logic
});

Please suggest the data binding way to attach the event handler on the Grid column header.

Best Regards,
Nilesh Padbidri​

Radoslav
Telerik team
 answered on 14 Aug 2015
1 answer
3.1K+ views
I have a DropDownList bound to an array that has fields for firstName and lastName.  I would like the display text to be firstName + " " + lastName.  How would I go about doing this?  I am not sure it supports templates and it seems data-text-field can only be set to one field.
Plamen
Telerik team
 answered on 14 Aug 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
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?