Telerik Forums
UI for ASP.NET MVC Forum
1 answer
395 views

I have tried to find som help on why i can't use this binding feature to my excel export part of the mvc grid compoment.

    var grid = $("#grid").data("kendoGrid");
    grid.bind("excelExport", function (e) {
        e.workbook.fileName = "Grid.xlsx";
    });
    grid.saveAsExcel();

 

This i my first beginning of these binding options, and the goal is to use them to hide/show during export.
To get to this goal, is need the first part solved first- my binding fails in the bold line in script performance on website.

 

The error is:Uncaught TypeError: Cannot read property 'bind' of undefined

 

Whay cant i use this bind to capure the excelExport event ??

 

regards

Allan

Tsvetomir
Telerik team
 answered on 30 Jul 2018
3 answers
448 views
Is there a way to bind a TreeList to a local datasource like you can with the grid?

With the grid, you can do this: @(Html.Kendo().Grid(Model)

The TreeList doesn't seem to like that.

Konstantin Dikov
Telerik team
 answered on 30 Jul 2018
5 answers
829 views
I am using an editor template to edit an entity that is represented by a view model. I have a grid in the editor template that in order to bind needs to have the primary key of the model passed to it in order to bind the images. How do I accomplish this?? Here is what I am currently doing which is NOT working:

From the grid .DataSource property:
.Read( read => read.Action( "BindImages", "CatalogAdministration" ).Data( "bind_images" ) )

"bind_images" javascript function:
function bind_images() {
 
    var grid = $("#GridInventoryItems").data("kendoGrid");
 
    grid.select().each(function () {
 
        var dataItem = grid.dataItem($(this));
 
        key = dataItem.InventoryItemId;
 
    });
 
    return {
        inventoryItemId: key 
    };
}

"BindImages" method in the controller:
public JsonResult BindImages( int? InventoryItemId )
{
    JsonResult result = null;
 
    if( InventoryItemId.HasValue )
    {
        result = Json( _GetImageViewModelRecords( InventoryItemId ) );
    }
 
    return result;
}

What is happening is that in the javascript function, the "Key" is always the previously edited record (because I don't know how to get the ID of the record beign currently edities, it looks like I am just grabbing the key of the selected row which is always going to be 1 behind). SO my first issue is how do I get the key of the row being edited?

Secondly, even when a valid ID is passed to the controller method and data is returned, it is never loaded into the grid. What am I doing wrong?

Instead of the .Data and passing a javascript function can't I just add to the route values using the .Route property? If so, how?

Any help is appreciated. Thanks!!
Steve
Top achievements
Rank 1
 answered on 29 Jul 2018
1 answer
1.0K+ views

     I've been trying to add a dropdown list to a grid cell for a while now and I can get the dropdown to appear but whenever it changes it doesn't seem to actually save the value.  When I choose a item the save event does end up firing but tabbing off of the field nothing has changed and the put doesn't get hit.  the other fields with just regular text boxes seem to work just fine.

Grid Code:

@(Html.Kendo().Grid<FieldTimeEntry.Web.Repos.Testing.DtsCrewDetLabor>()
                                                                                       .Name("dtsLaborGrid")
                                                                                       .ToolBar(toolbar =>
                                                                                       {
                                                                                           toolbar.Create();
                                                                                           toolbar.Save();
                                                                                       })
                                                                                       .Columns(columns =>
                                                                                       {
                                                                                           columns.Command(command => command.Destroy()).Width(100);
                                                                                           columns.Bound(p => p.EmpName);
                                                                                           columns.Bound(p => p.EmpNo);
                                                                                           columns.Bound(p => p.EmpBillCode);
                                                                                       })
                                                                                      .Editable(editable => editable.Mode(GridEditMode.InCell))
                                                                                      .Pageable()
                                                                                      .Navigatable()
                                                                                      .Sortable()
                                                                                      .Scrollable()
                                                                                          .Events(e =>
                                                                                          {
                                                                                              e.Save("onSave");
                                                                                              e.DataBound("onDataBound");
                                                                                          })
                                                                                       .DataSource(dataSource => dataSource
                                                                                           .Ajax()
                                                                                           .Batch(true)
                                                                                           .PageSize(20)
                                                                                           .ServerOperation(false)
                                                                                           .AutoSync(true)
                                                                                           .Model(m =>
                                                                                           {
                                                                                               m.Field(f => f.GfEmpNo).DefaultValue(Model.GfEmpNo);
                                                                                               m.Field(f => f.CrewCode).DefaultValue(Model.CrewCode);
                                                                                               m.Id(p => p.SeqNo);
                                                                                               m.Field(f => f.EmpNo);
                                                                                           })
                                                                                           .Create(create =>
                                                                                           {
                                                                                               create.Action("Create", "CrewsApi");
                                                                                               create.Type(HttpVerbs.Post);
                                                                                           })
                                                                                           .Read(read =>
                                                                                           {
                                                                                               read.Action("Get", "CrewsAPI", new { id = Model.CrewCode });
                                                                                               read.Type(HttpVerbs.Get);
                                                                                           })
                                                                                           .Update(update =>
                                                                                           {
                                                                                               update.Action("Put", "CrewsAPI");
                                                                                               update.Type(HttpVerbs.Put);
                                                                                           })
                                                                                           .Destroy(destroy =>
                                                                                           {
                                                                                               destroy.Action("Delete", "CrewsAPI");
                                                                                               destroy.Type(HttpVerbs.Delete);
                                                                                           })
                                                                                       ))

Editor Template:

@(Html.Kendo().DropDownList()
          .Name("EmployeeId")
          .DataTextField("NameAlpha")
          .DataValueField("EmployeeId")
          .DataTextField("NameAlpha")
          .DataValueField("EmployeeId")
          .Filter("contains")
          .OptionLabel("Select Employee")
          .AutoWidth(true)
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetEmployeesFiltered", "ReferenceData");
              })
              .ServerFiltering(true);
          })
          .Animation(a =>
          {
              a.Open(e =>
              {
                  e.Fade(FadeDirection.In);
              });
          }))

 

JS Events:

var lastEditIndex;
        function onSave(e) {
            lastEditIndex.row = this.tbody.children().index(e.container.parent());
            lastEditIndex.col = e.container.parent().children().index(e.container);
        }
 
        function onDataBound(e) {
            var grid = this;
            if (!$.isEmptyObject(lastEditIndex)) {
                var cell = grid.tbody.children().eq(lastEditIndex.row).children().eq(lastEditIndex.col);
 
                grid.current(cell);
                grid.table.focus();
            }
 
            lastEditIndex = {};
        }

 

 

Georgi
Telerik team
 answered on 27 Jul 2018
1 answer
1.5K+ views

Hello,

We used treelist which inside scrollable div  in our MVC project.  If we configured scrollable= false for treelist all column's width will mess up. If we used default setting (which is scrollable=true) the double scroll bar appeared which is not allowed in project. How to configured scroll bar only horizontally or vertically for Kendo UI treelist ?

Thanks

Preslav
Telerik team
 answered on 26 Jul 2018
2 answers
823 views

Hi ,

 

Hope you can help . I have a grid that is using SP via Enity Framework . If I do not using paging it pulls back all the records . However when I enable Paging it shows the correct number of pages but will only show the first 10 records ( or how many I set in PageSize() ) if I click on page 2, 3, , etc I see the same records .

This is my grid 

 

@model IEnumerable<SchoolsDisruptionPortal.Models.spSchoolsUserID_Result>
@{
    ViewBag.Title = "ListSchoolsUserID";
}
 
<h2>@Resource.SchoolUser</h2>
 
@(Html.Kendo().Grid(Model).Name("SchoolsUserID").Columns(c =>
{
    c.Bound(p => p.FriendlyName).Title(Resource.SchoolName).Width(450);
    c.Bound(p => p.Full_Name).Title(Resource.FullName).Width(300);
    c.Bound(p => p.Username).Title(Resource.UserName).Width(200);
 
 
 
 
})
.Pageable()
.ToolBar(tools => tools.Excel().Text(Resource.Export)).Excel(excel => excel.FileName(@Resource.SchoolUser + ".xlsx").AllPages(true))
.DataSource ( d => d
    .Ajax()
    .PageSize(30)
    )
 
)

 

I know it`s going to be something simple . It`s not a major requierment to my project but would make it look cleaner .

Julian
Top achievements
Rank 1
 answered on 26 Jul 2018
1 answer
1.3K+ views

I'm currently evaluating the Grid control, and managed to build my grid using c# using the html helper. 

My dataset has too many columns to put into one row and I trying to building a child grid using a client template to pass it the additional columns required. 

My c# function contain the bones of the child grid based upon an ExpandoObject, along with a local json array that I would like to insert into the datasource, can you tell me how I am able to achieve this?

var jsonColumns = Newtonsoft.Json.JsonConvert.SerializeObject ( row );

var grid = html.Kendo ().Grid<System.Dynamic.ExpandoObject> ()
       .Name ( "test" )
       .ToClientTemplate();

Konstantin Dikov
Telerik team
 answered on 26 Jul 2018
1 answer
605 views
Hello.

I try to update the item list in the multi checkbox filter popup by a separate datasource defined by a read action:
therefore I followed the instructions from the forum entry on
https://www.telerik.com/forums/refresh-multi-checkbox-filter-options-when-grid-is-filtered

Here a code snippet (MVC/Razor) :

 columns
    .Bound(column.Field)
    .Filterable(f =>
    {

        // check if field shall use checkbox filter
        if (Array.IndexOf(checkboxFilterFields, column.Field) >= 0)
        //if (column.Field == "StateType" || column.Field == "PhaseShortText")
        {
            f.Multi(true); // activate multi checkbox filter

            // setup checkbox filter list
            f.DataSource(ds => ds.Read(r => r
                .Action("ContractFilterListRead", "Contract", new
                {
                    field = column.Field
                }).Data("getFilterListReadParameters")
                )
            );
        }
    });
    
    
with a Javascript part:
    
<script>
    $(document).ready(function () {
        contractsGridController = new GridController('@(gridId)', '@(gridName)');

        //  bind click event of filter popup for checkbox filter list update
        $(".k-grid-filter").click(function (event) {
            //console.log("Gridfilter clicked");

            var fmc = $(event.target).closest("th").data("kendoFilterMultiCheck");
            if (fmc) {
                // update filter popup content
                fmc.checkSource.read();
                fmc.container.empty();
                fmc.refresh();
            }
        });
    });

    // getFilterReaderParameters gets client side filter and sort string
    getFilterListReadParameters = function () {
        console.log("getFilterReaderParameters()");
        var filterAndSortString = contractsGridController.getGrid().dataItem($(".k-grid-content tr")[0]).PFilterAndSortStr; // get filter and sort string of first data item
        console.log("Contract.Index: getFilterReaderParameters() filter and sort string: " + filterAndSortString);
        return { "filterAndSortString": filterAndSortString };
    };
</script>
    
This works like a charm if I use the grid filter mode "GridFilterMode.Menu".
If I switch to "GridFilterMode.Row" and add a Column Menu that contains the checkbox filter menu,
and changing the $(".k-grid-filter").click(function (event) part to $(".k-header-column-menu").click(function (event)
it doesn't work any more since the corresponding "th" element seems not having a kendoFilterMultiCheck object.
How can I access that kendoFilterMultiCheck of the Column Menu to update the item list?

BR, Matthias
Marin Bratanov
Telerik team
 answered on 25 Jul 2018
1 answer
585 views

I have a chart with a navigator which start and end points are being cut off.
See attached photo

I have fixed the end points being cut off by adding .Panes(panes => panes.Add().Clip(false))
However when I now use the navigator it when zooming in the lines in the chart are going outside the axis.

see attached photo.

Is there any way to fix both issues without affecting the other?

Thanks

Tsvetina
Telerik team
 answered on 25 Jul 2018
1 answer
152 views

It is possible with a "Normal" ReadAsync from the grid to provide more data without broken the DataSourceRequest response? I need to display some Azure User. Azure B2C has special way to achieve paging with NextLink token that I need to "store" in a hidden field. So the next time I receive a ReadAsync I can pass this NextLink and ask the correct page to the Azure API.

For now I can pass parameters from the view to the controller with the .data(javascript founction). But How I can get some custom parameter back in the RequestEnding function to store the info in hidden field?

 

Thanks

Konstantin Dikov
Telerik team
 answered on 25 Jul 2018
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
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
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?