Telerik Forums
UI for ASP.NET MVC Forum
7 answers
631 views

Hello,

I have a ui grid with code to hide the destroy button if only one record left in the grid:

...

columns.Command(command => { command.Destroy().Visible("isLastRecordEmail").Text("Remove"); }).Width(200);

...

                                            function isLastRecordEmail(e) {
                                                return $('\#GridEmails').data('kendoGrid').dataSource.data().length > 1;
                                            }

But if I click the Add button then a new records appears and destroy button will appear for last record to allow to delete the very last record.

My question is, how to hide the destroy button in this case?

I did try to add code:

 function isLastRecordEmail(e) {
      if ($('\#GridEmails').EditIndexes.Count > 0) return false;

but EditIndexes is undefined.

Could you please help?

Thanks!

Andrey
Top achievements
Rank 1
Veteran
 answered on 25 Jun 2019
1 answer
8.8K+ views

CostCenterController:

public ActionResult CostCenters_Read([DataSourceRequest] DataSourceRequest request)         {             return Json(ccService.Read().ToDataSourceResult(request));         }         [AcceptVerbs(HttpVerbs.Post)]         

public ActionResult CostCenters_Create([DataSourceRequest] DataSourceRequest request, CostCenterViewModel cc)         {             if (cc != null && ModelState.IsValid)             {                 ccService.Create(cc);             }             //return Json(cc, JsonRequestBehavior.AllowGet);             return Json(new[] { cc }.ToDataSourceResult(request, ModelState));         }         [AcceptVerbs(HttpVerbs.Post)]         

public ActionResult CostCenters_Update([DataSourceRequest] DataSourceRequest request, CostCenterViewModel cc)         {             if (cc != null && ModelState.IsValid)             {                 ccService.Update(cc);             }             return Json(new[] { cc }.ToDataSourceResult(request, ModelState));         }

 

Index.cshtml:

@(Html.Kendo().Grid<Main.Models.Quality.CostCenterViewModel>()                            

                                   .Name("CostCenter")                            

                                   .Columns(columns =>                            

                                    {columns.Bound(c => c.CostCenterID);                                

                                     columns.Bound(c => c.CC).Width(140);                                

                                     columns.Bound(c => c.Rate).Width(140);                                

                                     columns.Bound(c => c.Date).Width(100);                                

                                     columns.Command(command => command.Destroy()).Width(110);                            

                                     })                            

                                    .ToolBar(toolbar => toolbar.Create())                             

                                    .Editable(editable => editable.Mode(GridEditMode.PopUp))                            

                                    .Pageable()                            

                                    .Sortable()                            

                                     .Scrollable()                            

                                     .HtmlAttributes(new { style = "height:550px;" })                            

                                     .DataSource(dataSource => dataSource                            

                                     .Ajax()                            

                                     .PageSize(20)                            

                                     .Events(events => events.Error("error_handler"))                            

                                     .Model(model => model.Id(c => c.CostCenterID))                            .Create(update => update.Action("CostCenters_Create", "CostCenter"))                            .Read(read => read.Action("CostCenters_Read", "CostCenter"))                            .Update(update => update.Action("CostCenters_Update", "CostCenter"))                            .Destroy(update => update.Action("CostCenters_Destroy", "CostCenter"))                            

                            ))               

                            <script type="text/javascript">                    

                                   function error_handler(e) {                       

                                           if (e.errors) {                            

                                           var message = "Errors:\n";                            

                                      $.each(e.errors, function (key, value) {                                

                                           if ('errors' in value) {                                    

                                      $.each(value.errors, function () {                                     

                                       message += this + "\n";                                   

                                       });                                

                                     }                            

                                  });                            

                                 alert(message);  }                    

                                   }                

                                  </script>

I set CostCenterServer, the code is similar as ProductService.

It show up as normal, but when I Click "New Record", It popped up error with "This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."

 

In Controller, i tried to replace return Json(cc, JsonRequestBehavior.AllowGet); with return Json(new[] { cc }.ToDataSourceResult(request, ModelState)); but no lucky??

Georgi
Telerik team
 answered on 25 Jun 2019
1 answer
134 views

Hello,

What is the best practice to use Kendo UI grid with "long run" server side data source? I have a web page with two tabs. The grid in on second page. The data downloaded on login process and average time is about 20-30 seconds, that's not good. If I create remote data source then opening the second tab is taking 20 seconds to display the grid content.If I choose the first tab and then return the second tab then the grid takes 20 seconds again.

The amount of records in the data source is 0-5. The problem is that SQL code has to check too many things (and controller accessing another web site) and cannot be optimized.

Should I go with web workers? In this case the data could be downloaded when the first tab is displaying. Or might be exist another solution? Or something already in grid functionality that I have missed? What is the best practice for such case?

Thanks!

Andrey
Top achievements
Rank 1
Veteran
 answered on 24 Jun 2019
10 answers
1.2K+ views
I'm having an issue with the ForeignKey drop down not showing the selected value when I pick the first one in the list.

To reproduce, go to the Foreign Key Column example(http://demos.kendoui.com/web/grid/foreignkeycolumn.html), add a new row, put a value in for the product name, select "Beverages" for the category, then click on the Unit Price cell.  Observe that the category cell now is blank instead of showing the selected "Beverages" value.

Any help would be much appreciated.
Thanks,
--Evan
Viktor Tachev
Telerik team
 answered on 24 Jun 2019
2 answers
280 views

I have two applications which both manage hierarchies using treeviews, allowing dragging and dropping of items into a hierarchy tree.

Sample1.jpg shows the working application, whilst Sample2.jpg shows the problem one.

They both work, but on one, the treeview correctly displays the lines to indicate where an item will be dropped, whilst in the other, the line is not shown apart from a tiny dot.  I've compared the two applications, and switched out the bootstrap themes and styles, and cannot identify the issue. In the DOM explorer, the treeview styles look the same.

The malfunctioning application is using version 2019.1.220 of the framework.

Any help to fix this issue would be appreciated.

Thanks

AP
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 20 Jun 2019
6 answers
990 views

Hai. So, I have view and I loaded column chart on this view like partial view(chart diagram). And I have a little problem, I can't to send data from controller. I need to load data after sorting data. I send service id and after that, loading chart with data only for this service.
Load main view => send data in controller with service id => in contoller do query for database => load data in partial chart view => display partial view chart data in main view

//Partial view
@Html.Partial("~/Views/Graphs/TableStatementsChart.cshtml", new ViewDataDictionary { { "Id", Model.servicesModel.Id } })
 
//contoller
public ActionResult TableStatementsChart(int Id)
        {
            ViewBag.IdService = Id;
 
            return View("~/Views/Graphs/TableStatementsChart.cshtml");
        }
 
        [HttpPost]
        public ActionResult TableStatements_Read(int Id)
        {
            int localId = Id;
 
            return Json(db.TableStatements.Select(tableStatements => new
            {
                fkIdServices = tableStatements.fkIdServices,
                Month = tableStatements.Month,
                Count = tableStatements.Count,
                DoneCount = tableStatements.DoneCount,
                TopicalCount = tableStatements.TopicalCount
            }).Where(x=>x.fkIdServices == Id));
        }
//Chart diagram
@{
    Layout = "~/Views/Shared/_LayoutKendoUIChart.cshtml";
}
 
@(Html.Kendo().Chart<NarkomApp.Models.TableStatements>()
      .Name("chart")
      .Title("Заявки")
      .Legend(legend => legend.Position(ChartLegendPosition.Bottom))
      .Tooltip(tooltip => tooltip.Visible(true))
      .DataSource(ds => ds.Read(read => read.Action("TableStatements_Read", "TableStatementsChart")))     
      .Series(series =>
      {
          series.Column(a => a.Count).Name("Общее").Color("red");
          series.Column(a => a.DoneCount).Name("Выполненные").Color("blue");
          series.Column(a => a.TopicalCount).Name("Актуальные").Color("green");
      })
      .CategoryAxis(axis => axis
      .Categories(model => model.Month).Labels(labels => labels.Rotation(-90)))
)

 

Meypar
Top achievements
Rank 1
 answered on 19 Jun 2019
3 answers
300 views

I installed the telerik extensions and used it to create a new "Telerik MVC" project.  Compiling warns about dll conflicts and if you run the base project it errors with a similar error.

Should I assume Telerik is not quite stable with studio 2019?

Vesko
Telerik team
 answered on 18 Jun 2019
1 answer
1.2K+ views

HI all  I'm Kind of new to Grids  

i want to build an grid  which looks kind of this 

Grid Title | Column Title  | Column Title | 

row  Title | Value             | Value            |

row  Title | Value             | Value            |

row  Title | Value             | Value            |

 

The "title" fields should not get a static content so they should not be retrieved from the database,

the "value" fields should be "dynamic" and get their content from a database. 

Now my question : how do I create these "static" fields? 

Marin Bratanov
Telerik team
 answered on 14 Jun 2019
1 answer
807 views

So we recently updated our version of kendo to 2015.2.805.

The error ("Uncaught TypeError: Cannot read property 'value' of undefined") is caused by line 3 of the following JavaScript ("multiselect" on line 1 is undefined):

1.var multiselect = $("#Statuses").data("kendoMultiSelect");
2.var selectedData = [];
3.var items = multiselect.value();

 

Initialization code:

1.<label>Statuses</label>
2.@(Html.Kendo().MultiSelect()
3.    .Name("Statuses")
4.    .Placeholder("Select statuses...")
5.    .BindTo(Model.AllStates)
6.    .ItemTemplate("<span class=\"workflow-state #:getStateClass(data.Value)#\">#:data.Text#</span>")
7.    .TagTemplate("<span class=\"workflow-state #:getStateClass(data.Value)#\">#:data.Text#</span>")
8.    .Value(Model.SelectedStatuses))

When testing this code on a previous version of the application, the feature works. However, since that version we have updated kendo, as well as the references to kendo (in _Layout.cshtml).

Could this maybe be a reference issue?

Regardless of whether we add or remove kendo.web.min.js, the problem persists.

We are referencing the following files, all of these files return an OK result:

1./kendo/2015.2.805/kendo.all.min.js
2./kendo/2015.2.805/kendo.aspnetmvc.min.js
3./kendo/2015.2.805/cultures/kendo.culture.en-GB.min.js
4./kendo/2015.2.805/kendo.web.min.js
Veselin Tsvetanov
Telerik team
 answered on 14 Jun 2019
6 answers
738 views

Would someone be able to offer any suggestions on how to display TreeView with certain node paths already expanded based on a "expandFolder" boolean attribute that is returned in the Remote_Data_Binding controller?

I'm using code similar to the below example with an additional "expandFolder" boolean attribute on the database.
https://demos.telerik.com/aspnet-mvc/treeview/remote-data-binding

 

Additionally, when a user clicks a node, the tree needs to fully expand any child nodes whose "expandFolder" is true.

I saw some posts about an "expand: true" setting topic but couldn't figure out how to use that approach with the LoadOnDemand treeview pulling from remote data binding.  I also saw some uses with expandPath.  However, I was hoping there's a way to use the existing node data without having to re-traverse the entire tree since I already set the expandFolder in the Controller?

Thanks in advance for any help,

Gil

 

 

 

Dimitar
Telerik team
 answered on 14 Jun 2019
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
Security
ColorPicker
DateRangePicker
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
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?