Telerik Forums
UI for ASP.NET MVC Forum
5 answers
4.5K+ views

I am developing a server side grid page ,i have googled it and did not find the correct behavior for me,

I need to each page size change dynamically and also the total number be set not via result len because i want to show user  that we have for example 10000 pages but each time send him only 100 when i do so if my page size is 100

               
         .DataSource(dataSource => dataSource
        .Custom()
        .Type("aspnetmvc-ajax")
        .ServerPaging(true)        
        .ServerSorting(true)
        .ServerFiltering(true) 
        .Transport(transport => transport
            
            .Read(read => read.Action("GetTodaysSalesList", "Sales")                              
            .Data("filterData"))

        )
        
        .Schema(schema => schema.Model(model =>
        {
            model.Id(p => p.RowID);
            model.Field(p => p.InvestorID).Editable(true);
            model.Field(p => p.LoanNumber).Editable(false);
            model.Field(p => p.LoanStatus).Editable(false);
            model.Field(p => p.LoanCategory).Editable(false);
            model.Field(p => p.CRBFundedDate).Editable(false);
            model.Field(p => p.NoteDate).Editable(false);
            model.Field(p => p.LoanAmount).Editable(false);
            model.Field(p => p.NetFunding).Editable(false);
            model.Field(p => p.Rate).Editable(false);
            model.Field(p => p.XIRR).Editable(false);
            model.Field(p => p.DateOfSale).Editable(false);
            model.Field(p => p.DaysOutstanding).Editable(false);
            model.Field(p => p.AccruedInterest).Editable(false);
            model.Field(p => p.CRBOriginationFee).Editable(false);
            model.Field(p => p.ImputedInterest).Editable(false);
            model.Field(p => p.Platform).Editable(false);
        }).Data("Data").Total("Total"))          

this controller side i have tried some options

option one:

   var test = _loans.ToDataSourceResult(request);
                test.Total = 1000;
                return   Json(test, JsonRequestBehavior.AllowGet);

 option two

              
                return   Json( new {Data=loans.ToDataSourceResult(request) Total=10}, JsonRequestBehavior.AllowGet);

 

 

the total has no influnce

Alex Hajigeorgieva
Telerik team
 answered on 10 Nov 2020
4 answers
1.4K+ views

Hello friends. My second day with Kendo UI for ASP.NET MVC (newbie questions):

tl;dr version:

This:

@Html.HiddenFor(model => model.ProjectID)
 
... lines ommitted for brievity
 
.ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='" + Url.Action("Index", "PurchaseInvoice/#= ProjectID #")+"'>#= kendo.format('{0:C}',sum)#</a></div>");

generates this:

<a href="/PurchaseInvoice/[object HTMLInputElement]">$191,449.65</a>

 which shows the amount as a link (great). But what I need to be generated is this:

<a href="/PurchaseInvoice/259">$191,449.65</a>

... where 259 is the ProjectID.

Note that ProjectID is part of the model, but not of the grid's data. That's likely my problem here.

What am I missing? Is there an easier way to do this?

Long version:

@(Html.Kendo().Grid<DataLibrary.ProjectCost>()
    .Name("CostGrid")
    .Columns(columns =>
    {
        columns.Bound(c => c.Month)
            .Width(100)
            .Title("Mois")
            .Hidden();
        columns.Bound(c => c.SupplierName)
            .Width(300)
            .Title("<div style='text-align:left;'>Fournisseur </div>")
            .HtmlAttributes(new { @style = "text-align:left;" })
            .ClientFooterTemplate("<div style='text-align:right;'>TOTAL: </div>");
        columns.Bound(c => c.OrderAmount)
            .Format("{0:C}")
            .Width(100)
            .Title("Commandé")
            .HtmlAttributes(new { @style = "text-align:right;" })
            .ClientGroupHeaderColumnTemplate("#= kendo.format('{0:C}',sum)#")
            .ClientFooterTemplate("<div style='text-align:right;'>#= kendo.format('{0:C}',sum)#</div>");
        columns.Bound(c => c.InvoiceAmount)
            .Format("{0:C}")
            .Width(100)
            .Title("Facturé")
            .HtmlAttributes(new { @style = "text-align:right;" })
            .ClientGroupHeaderColumnTemplate("#= kendo.format('{0:C}',sum)#")
            .ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='" + Url.Action("Index", "PurchaseInvoice/#= projectID #")+"'>#= kendo.format('{0:C}',sum)#</a></div>");
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Aggregates(aggregates =>
        {
            aggregates.Add(c => c.OrderAmount).Sum();
            aggregates.Add(c => c.InvoiceAmount).Sum();
        })
        .Group(groups =>
        {
            groups.AddDescending(c => c.Month);
        })
        .Read(read => read.Action("CostSummary", "Project", new { ID = Model.projectID }))
    )
    .Events(events => events.DataBound("collapseGroupRows"))
)

 

I've tried many variations:

.ClientFooterTemplate("<div style='text-align:right;color:blue;'>#= kendo.format('{0:C}',sum)#</div>");
.ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='/PurchaseInvoice?ProjectID=#=projectID#'>#= kendo.format('{0:C}',sum)#</a></div>");
.ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='/PurchaseInvoice?ProjectID=#=projectID#>#= kendo.format('{0:C}',sum)#</a></div>");
.ClientFooterTemplate("<div style='text-align:right;color:blue;'><a href='/PurchaseInvoice?ProjectID=#=projectID#>#= kendo.format('{0:C}',sum)#</a></div>");
.ClientFooterTemplate(@Html.ActionLink("#= kendo.format('{0:C}',sum)#","Index", "PurchaseInvoice", new { ProjectID = "#= projectID#" }, null).ToHtmlString());
.ClientFooterTemplate(@Html.ActionLink("#= kendo.format('{0:C}',sum)#","Index", "PurchaseInvoice", new { ProjectID = "#=projectID#" }, new { @style = "text-align:right;color:blue;" }).ToHtmlString());
.ClientFooterTemplate(@Html.ActionLink("#= kendo.format('{0:C}',sum)#","Index", "PurchaseInvoice", new { ProjectID = "#= projectID#" }, null ).ToHtmlString());
.ClientFooterTemplate(@Html.ActionLink("#= kendo.format('{0:C}',sum)#","Index", "PurchaseInvoice", new { ProjectID = "#= projectID#" }, null ).ToHtmlString());

 

Perhaps one of these is a (almost) better implementation (none of these work as-is though).

Thanks

Francois
Top achievements
Rank 1
 answered on 10 Nov 2020
3 answers
745 views

hi

I try to show my image instead of the icon of image in viewer.

i use 

.Views(v=>v.List(a=>a.TemplateId("template")))

 

<script id="template" type="text/kendo-ui-template">
<img src="~/Content/UserFiles/Folders/Images/demos-web.png"/>  
</script>

 

bot it dose not show any things.

i upload two image show with template and without template.

thank you.

mehran
Top achievements
Rank 1
 answered on 10 Nov 2020
6 answers
195 views

Hi all,

I need to do a Multi Filter on a column that can has more that one value. For example the value in the column contains the values Blue and Green. When a user selects blue in the multi select as a option I would like for any row that has blue in that that column to be returned. For further explanation see this dojo I created to explain what I am trying to do.

 

I am also looking to create a custom filterable ui widget  that uses the kendoMultiSelect and a custom filter on the data source that will make use of my custom filterable ui widget. I am not sure if this will work. Any help on this would be great.

Brandon
Top achievements
Rank 1
 answered on 09 Nov 2020
9 answers
1.1K+ views

How can I submit the wizard's model to the Controller.i.e. on Done(), how can submit the binded model to the controller?

please hep. I am new and stuck on this.

Marconi
Top achievements
Rank 1
Veteran
 answered on 08 Nov 2020
2 answers
1.0K+ views

Hi Team,

 

Currently i am working on KenoMvc Grid , which have group by  on two columns and we are showing aggregates in  group footers.

On inline row delete row got deleted but aggregates not updating . Please explain me what could be the reason. 

Please help me to understand the grid refresh on edit.

 

 

Thanks & Regards,

Purnima.

Sp
Top achievements
Rank 1
Veteran
 answered on 06 Nov 2020
13 answers
217 views

I am trying to render a grid hierarchy. Here is my code.

Parent Grid

@Code
    Html.Kendo().Grid(Of BenchStatusIndicatorMVC.Target)() _
        .Name("Grid") _
        .ToolBar(Function(t)
                     t.Search()
                 End Function) _
        .Columns(Sub(c)
                     c.Bound(Function(p) p.StandardId)
                     c.Bound(Function(p) p.PC)
                     c.Bound(Function(p) p.DateEntered)
                     c.Bound(Function(p) p.DateModified)
                     c.Bound(Function(p) p.Type)
                 End Sub) _
        .Pageable(Sub(x)
                      x.PageSizes(True)
                  End Sub) _
        .ClientDetailTemplateId("template") _
        .Sortable() _
        .Filterable() _
        .DataSource(Function(d)
                        d.Ajax() _
        .Read(Function(read) read.Action("Target_Read", "Target")) _
        .ServerOperation(False) _
                        .Model(Sub(m)
                                   m.Id(Function(i) i.StandardId)
 
                               End Sub)
                    End Function) _
        .Render()
End Code     
Nikolay
Telerik team
 answered on 06 Nov 2020
7 answers
1.3K+ views

I'm trying to set up an upload for some quite large files, which involves using chunked asynchronous uploads.

Once the file has been transferred, a record is saved to a database, with details of the file name, and an ID passed back to the web page.

I was able to get this working when the upload wasn't using chunks, but I'm now a bit stuck.

The example in your documentation (https://docs.telerik.com/aspnet-mvc/html-helpers/editors/upload/chunk-upload ) seems to be written for .later versions of the >NET framework (or .NET core), as I cannot find namespaces to include IFormFile or JsonSerializer . I'm using .NET Framework 4.7.2

I have got a version working (the file is saved to the upload folder), however, when the upload is complete, it does not call the Save procedure., which saves a record to a database, renames the file, and passes back a fileID.

The code is:-

public ActionResult ChunkSave(IEnumerable<HttpPostedFileBase> files, string metaData)
        {
 
           if (metaData == null)
            {
                return Save(files);
            }
 
            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(metaData));
            var serializer = new DataContractJsonSerializer(typeof(ChunkMetaData));
            ChunkMetaData chunkData = serializer.ReadObject(ms) as ChunkMetaData;
 
            string path = String.Empty;
            string uploadFolder = SystemsPortal.Properties.Settings.Default.GLInterfaceUploadFolder;
 
            if (chunkData.chunkIndex == 0)
            {
               //1st chunk - check if file exists, and if so, delete before saving
                path = Path.Combine(uploadFolder, chunkData.fileName);
 
                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }
 
            }
 
            path = String.Empty;
            // The Name of the Upload component is "files"
            if (files != null)
            {
                foreach (var file in files)
                {
                    path = Path.Combine(uploadFolder, chunkData.fileName);
 
                    AppendToFile(path, file.InputStream);
                }
            }
 
            Models.FileResult fileBlob = new Models.FileResult();
            fileBlob.uploaded = chunkData.totalChunks - 1 <= chunkData.chunkIndex;
            fileBlob.fileUid = chunkData.uploadUid;
 
           
           return Json(fileBlob);
             
 
            
        }

The control definition is:-

@(Html.Kendo().Upload()
.Name("files")
.Multiple(false)
.Events(e => e.Success("ulSuccess"))
 
.Async(a => a
    .Save("ChunkSave", "GLInterfaceUpload")
    .ChunkSize(250000)
     
   
    .AutoUpload(true)
)
 
)


function ulSuccess(e) {


var response = e.XMLHttpRequest.responseText;
fileID = response;
alert(fileID);
e.sender.enable(false);
$('#divButton').show();


}

 

 

The Success event does fire, but the data returned, but as the Save procedure has never been called, no fileID is passed back.

How can I get this working as it should?

 

Thanks

Ivan Danchev
Telerik team
 answered on 06 Nov 2020
1 answer
1.0K+ views

Hello. I am trying to find a way to Expand/Collapse columns for a Kendo Grid in MVC. I see this implementation for js:

https://docs.telerik.com/kendo-ui/knowledge-base/grid-expand-collapse-columns-group-button-click

But I would like to find the same functionality example for MVC please.

Nikolay
Telerik team
 answered on 06 Nov 2020
3 answers
1.0K+ views

.ClientTemplate() is not working inside the child grid. I'm also posting the example explaining the issue.

 

This is the Parent grid:

                @(Html.Kendo().Grid(Model.DeliquencRulesGridVM)
                            .Name("deliquencRulesGridVM")
                            .Columns(columns =>
                            {
                                columns.Bound(c => c.Id).Hidden();

                                columns.Bound(c => c.RuleNumber)
                                .Title(@AonWrapStringResources.Deliquency_Label_RuleNumber)
                                .Width(200)
                                .HtmlAttributes(new { })
                                .Filterable(f => f.Extra(false)
                    .Messages(m => m.Info(@StringResources.Generic_GridFilter_Refine + " " + @AonWrapStringResources.Deliquency_Label_RuleNumber + ":")));

                            })
                    .ClientDetailTemplateId("deliquency-grid")
                    .Events(e => e
                        .DataBound("delinquency.gridDataBound")
                     )
                .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .PageSize(10)
                        .Model(model =>
                        {
                            model.Id(p => p.Id);
                        })
                        .ServerOperation(false)

                        )
                .Resizable(resize => resize.Columns(true))
        .Deferred()
        )

 

And this is the child grid in which .ClientTemplate() is not working.

<script id="deliquency-grid" type="text/kendo-tmpl">
            <div id="DeliquencyFollowUpGrid">
                <div class="grid-outside">
                    @(Html.Kendo().Grid(Model.DeliquencFollowUpGridVM)
                       .Name("deliquencFollowUpGridVM")
                      .Columns(columns =>
                      {
                           columns.Bound(c => c.Active)
                           .Title(@AonWrapStringResources.BrowseProgram_Label_Active)
                .Template(@<text></text>)
                                .HtmlAttributes(new { @class = "text-center" })
                                .ClientTemplate("Hello")
                                .Width(102);

                            })
                    .Events(e => e
                        .DataBound("delinquency.gridFollowUpDataBound")
                     )

                .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .PageSize(10)
                        .Model(model =>
                        {
                            model.Id(p => p.Id);
                        })
                        .ServerOperation(false)

                        )
                .Resizable(resize => resize.Columns(true))
        .Deferred()
        .ToClientTemplate()
        )
                </div>
            </div>

        </script>

 

Could you please help me on this. It would be much appreciated if you can help me on this.

 

Petar
Telerik team
 answered on 05 Nov 2020
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
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?