Telerik Forums
UI for ASP.NET MVC Forum
2 answers
1.6K+ views
Hello,

I am wondering how I can get the total rowcount while inside the ondatabound event ?   

Here is the background of why I am looking for this info.   I am trying to code in a row cap lets say of 250 records which will be done in the controller.  However I have a requirement that if the query was capped I need to offer the user an option to view all the rows.   Basically implementing an alert to the user that they ran a query that returns a large set of data.   At first they will only get the 250 rows but they are given an option to return all rows like a button or something which would rebind the grid and grab all rows from the controller.

I am sending a parameter in the Action call to bind that specifies whether or not to show all records, but I need to figure out how to get a row count so I know if the initial databind hit the cap. 

Here is my code:
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .HtmlAttributes(new { style = "font-size:.85em;" })
    .Columns(columns =>
    {
        columns.Bound(p => p.Id).Width(60);
        columns.Bound(p => p.Title).Width(250);
        columns.Bound(p => p.AssignedUser).Width(120);
        })
    .Pageable()
    .Groupable()
    .Sortable()
    .Filterable(filterable => filterable
      .Extra(false)
      .Operators(operators => operators
                          .ForString(str => str.Clear()
                          .StartsWith("Starts with")
                          .Contains("Contains")
                          .IsEqualTo("Is equal to")
                          .IsNotEqualTo("Is not equal to")))
      )
   .Selectable(selectable => selectable
      .Mode(GridSelectionMode.Single))
   .DataSource(dataSource => dataSource
               .Ajax()
               .Read(read => read.Action("Get", "Grid", new {showAll = ViewBag.ShowAll}))
               )
   .Events(e => e.Change("onChanged").DataBound("onDataBound"))
)
Carrie
Top achievements
Rank 1
 answered on 05 Sep 2013
1 answer
421 views
I have two model.
When I want to display a list of Product in grid, if PurchaseInvoiceDetail have records, Product grid show empty list,
and when i delete PurchaseInvoiceDetail records, Product's grid display list of product.
(I use Editing_Popup grid)
public class Product
    {
        [Key]
        [ScaffoldColumn(false)]
        public int ProductId { get; set; }       
        public string Name { get; set; }
        public int Number { get; set; }
 
        public virtual ICollection<PurchaseInvoiceDetail> PurchaseInvoiceDetail { get; set; }
    }
 
public class PurchaseInvoiceDetail
    {
        [Key]
        public int PurchaseInvoiceDetailId { get; set; }
        public int Number { get; set; }
        public decimal PurchasePrice { get; set; }
 
        //Navigation Properties
 
        public int ProductId { get; set; }
        public virtual Product Product { get; set; }
    }
Dimiter Madjarov
Telerik team
 answered on 05 Sep 2013
2 answers
123 views
So if have a chart that represent data over a period of time like current fiscal quarter, that date would be from beginning of July through end of September. So the chart would draw a period of time ranging those 3 months. However, if the most recent data goes until current day minus one, the series drawn on the chart dips down to "0". What I am after with modifying some existing code is for when the series is drawn, it stops drawing the series (for a line chart) at today(-1) and does not make the series (line) go further where no data is yet represented since it is in the future. This said, I hope I was descriptive enough and am hoping some of you could post some examples I could reference that does draw a chart over coarse of time with the series not going the full span of time. Could not find any particular documentation on this. Appreciate the help. Thanks much.
Iliana Dyankova
Telerik team
 answered on 05 Sep 2013
3 answers
88 views
Previously, I added an icon and a title to my mobile app like this: 

window.app = new kendo.mobile.Application(document.body, {
    layout: "mainLayout",
    skin: "flat",
    hideAddressBar: true,
    icon: "Images/FileName.png",
    title: "App Name"
});
Whereas now, I can't seem to figure out how to do this. Any suggestions? :)
Alexander Valchev
Telerik team
 answered on 05 Sep 2013
1 answer
100 views
Hi,
I am using the Asp.Net Mvc Wrapper for the scheduler control. I noticed that if I specify an editor template, the delete confirmation message does no longer appear:

To clarify, with this declaration the confirmation message does not appear:

.Editable(e => { 
 e.TemplateId("editEventTemplate");
e.Confirmation(true);
 }) 

If I remove all the "Editable" configuration or if I leave just the Confirmation part, it works correctly:

.Editable(e => { 
e.Confirmation(true);
 }) 

What could be the reason for this strange behaviour?
Thanks,
Stefano Tassara
Vladimir Iliev
Telerik team
 answered on 05 Sep 2013
9 answers
2.2K+ views
Hello!
I always get Error: GET ~/Scripts/kendo/2013.1.703/jquery.min.map 404 (Not Found)
I update Kendo to Q2 , but this error dosn't disappear
Atanas Korchev
Telerik team
 answered on 05 Sep 2013
1 answer
90 views
It seems like the objects are not being passed into listview editor templates at all now.

Latest internal build 2013.2.830.commercial
iCognition
Top achievements
Rank 1
Iron
 answered on 04 Sep 2013
10 answers
93 views
Hello,

there is a new exclusive IE8 bug in the 2013 Q2 release  which is easily reproduceable with the Online Kendo Demos.

If you change the "Font" Drop-Down (e.g: Heading 1, Heading 2), a javascript error occurs in "kendo.web.js":
Object doesn't support property or method 'indexOf'

Can you please put the fix in the next Internal Build.


Uriah
Top achievements
Rank 1
 answered on 04 Sep 2013
3 answers
238 views
I want to be able to select a row in a parent grid and be able to see (and edit or add) all of it's children. The parent is a lessor and the child is the leased equipment. I created a through away project where I get the expected behavior but when I implement it my real project it is not working. I have verified I am getting a JSON response back from my controller but the grid is not filling in with the data.

Here is my stripped down code from the razor view:


@using Cci.Web.PPDeclaration.Models


@(Html.Kendo().Grid<Cci.Web.PPDeclaration.Domain.DbEntities.Lessor>()
.Name("LeasingGrid")
.Columns(columns =>
{
columns.Bound(l => l.LessorId).Hidden(true);
columns.Bound(l => l.LessorName).Title("Lessor").Width(175);
}
)
.Selectable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetLessors", "Leasing"))
.Events(events => events.Error("error_handler"))
)
.Events(events => events.Change("change"))
)


@(Html.Kendo().Grid<Cci.Web.PPDeclaration.Domain.DbEntities.Lease>()
.Name("LeaseGrid")
.Columns(columns =>
{
columns.Bound(m => m.LeaseDetail).Width(250).Title("Property Description");
columns.Bound(m => m.LeaseNumber).Width(80).Title("Lease Number");
})
.AutoBind(false)
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("SelectLease", "Leasing").Data("data"))
.Events(events => events.Error("error_handler"))
)

)


<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);
}
}

function change() {
$("#LeaseGrid").data("kendoGrid").dataSource.read();
}

function data() {
var grid = $("#LeasingGrid").data("kendoGrid");

return {
lessorId: grid.dataItem(grid.select()).LessorId
}

}
</script>


@section Javascript
{

<script src="@Url.Content("~/Scripts/kendo/2013.2.716/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2013.2.716/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2013.2.716/kendo.aspnetmvc.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
<script src="@Url.Content("~/Scripts/EditableGrids.js")"></script>
}

Here is the controller code:
public class LeasingController : System.Web.Mvc.Controller
{
private ILeasingRepository _repository;

public LeasingController() : this(new LeasingRepository())
{
}

public LeasingController(ILeasingRepository repository)
{
_repository = repository;
}

public ActionResult Index()
{
return View();
}

#region Lessors

public ActionResult GetLessors([DataSourceRequest]DataSourceRequest request)
{
LeasingModel model = new LeasingModel { Lessors = _repository.GetActiveLessors(SessionData.AccountNo) };
return Json(model.Lessors.ToDataSourceResult(request));
}

#endregion

#region leases
public ActionResult GetLeases([DataSourceRequest]DataSourceRequest request)
{
LeasingModel model = new LeasingModel { Leases = _repository.GetActiveLeases(SessionData.AccountNo) };
return Json(model.Leases.ToDataSourceResult(request));
 }

public ActionResult SelectLease([DataSourceRequest]DataSourceRequest request, int lessorId)
{
SessionData.LessorId = lessorId;
return Json(new[] { FilteredLeases() }.ToDataSourceResult(request, ModelState),JsonRequestBehavior.AllowGet);
}

private List<Lease> FilteredLeases()
{
return _repository.GetActiveLeases(SessionData.AccountNo).Where(ls => ls.LessorId == SessionData.LessorId).ToList();
}

#endregion

Any help will be appreciated.

Thanks,
Dave Brown

P.S. I've also attached the through away project.
Vladimir Iliev
Telerik team
 answered on 04 Sep 2013
1 answer
219 views
Hello,
I'm using KENDO UI grid in mvc4 application and following your tutorial for ajax binding I'm doing something  as

public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
{
using (var northwind = new NorthwindEntities())
{
IQueryable<Product> products = northwind.Products;
// Convert the Product entities to ProductViewModel instances
DataSourceResult result = products.ToDataSourceResult(request, product => new ProductViewModel
{
ProductID = product.ProductID,
ProductName = product.ProductName,
UnitsInStock = product.UnitsInStock
});
return Json(result);
}
}

Now I need to add an export in PDF/csv function... I was wondering since you don't offer it out of the box to store a guid of the retieved data and pass it back to
the client...at the button click I'll pass this data back to the server and export the data if still present in cache otherwist I'll remake the call...
now I've tried adding a TempData["guid"] just before the Json(result) but with no luck.. should I change the binding method? and use a pure kendoui grid passing back an object as
Result { Guid ID {get;set; } IEnumerable<type> DataItems {get;set}} ?

Thanks
Petur Subev
Telerik team
 answered on 04 Sep 2013
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
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?