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

I have a client side datasource grid with several count and sum aggregates that display their data correctly, but they doesn't update when a user filters a column that affects the result of such aggregates. Is it possible to do that? The only way I can think of is with an event that updates the footer, but I don't know how to achieve this.

My grid was created using razor.

Thanks in advance.

Viktor Tachev
Telerik team
 answered on 14 Jun 2016
1 answer
92 views

Hi,

I am trying to load SQL server data into a dropdownlist in an MVC project, database
first and it works fine as the long as the table is not joined in the
model diagram.

As soon as i bring other tables that are linked to the
one i need, the dropdown does not load data anymore.

Am I missing something?
How can i solve this?

Thx

Adrian

Nencho
Telerik team
 answered on 14 Jun 2016
3 answers
147 views
How to navigate through multilevel kendo mvc menu through keyboard. Right now tab only works for the first level items. The menu demos does not show keyboard navigation.
Ivan Danchev
Telerik team
 answered on 14 Jun 2016
1 answer
1.3K+ views

I am using kendo Grid of kendo of ASP.NET MVC 2016.1.412.

My code where I want to get selected is:

 

column.Bound(e => e.Username).Title("Username").Groupable(true).ClientTemplate("<a style='cursor:pointer' onclick=EditProductDataObject(Username)>#=Username#</a>");

 

Here instead of username I want to pass whole row object so I can read and use further the coming data.

Eyup
Telerik team
 answered on 14 Jun 2016
1 answer
205 views

I have a very basic grid that I built with the telerik mvc grid scaffolding.

 

I have a column called "parent"  that parent should display a 10 digit number, instead it displays "function (){return o}"

 

I have tried templating, toString and it shows the same thing.  every other column works as expected

 

 

@(Html.Kendo().Grid<AccountMove.act_trans_worktable>()
      .Name("grid")
      .Columns(columns =>
      {
          columns.Bound(c => c.customer_name);
          columns.Bound(c => c.reason);
          columns.Bound(c => c.parent);
      })
      .Pageable()
      .Navigatable()
      .Sortable(sortable =>
      {
          sortable.SortMode(GridSortMode.SingleColumn);
      })
      .Filterable()
      //.Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .Read(read => read.Action("act_trans_worktable_Read", "mvcgrid"))
      )
)

Marin
Telerik team
 answered on 13 Jun 2016
9 answers
2.3K+ views

I have a editable Kendo grid with two datepicker inside, the kendo grid and it's controller are part an MVC Area. When i want to save a row the error is shown saying that the value introduced is not valid, i want the date format as dd/MM/yyyy. Those date fields have a template like this:

 

@(Html.Kendo().DatePicker()
        .Name("date")
        .Culture("es-MX")
        .Format("{0:dd/MM/yyyy}")
        .ParseFormats(new string[] { "dd/MM/yyyy" })
)

 

also in the columns definition have format and even a js function to get the value as i want

.Columns(columns =>
    {
        columns.Bound(p => p.InicioVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(InicioVigencia)#");
        columns.Bound(p => p.FinVigencia).Format("{0:dd/MM/yyyy}").ClientTemplate("#=getDate(FinVigencia)#");

}

function getDate(object) {
            if (object == null || object == "null" || object == "NULL" || object == "Null")
                return "";
            return kendo.toString(object, "dd/MM/yyyy");
        }

 

In the global.asax i set this properties in order to have the date format i want.

CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();

            threadCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            threadCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";
            uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";

            Thread.CurrentThread.CurrentCulture = threadCultureInfo;
            Thread.CurrentThread.CurrentUICulture = uiCultureInfo;

But the system still showing the error, i have other datepickers defined as js in orther controller just like this

$(function () {
        $(".date-picker").kendoDatePicker({
            animation: {
                close: {
                    effects: "fadeOut zoom:out",
                    duration: 300
                },
                open: {
                    effects: "fadeIn zoom:in",
                    duration: 300
                }
            },
            format: "dd/MM/yyyy",
            culture: "es-MX"
        });
    });

And everyting is working fine, so i don't know why it is not working properly. if i change global.asax like this

CultureInfo threadCultureInfo = (CultureInfo)CultureInfo.CurrentCulture.Clone();
            CultureInfo uiCultureInfo = (CultureInfo)CultureInfo.CurrentUICulture.Clone();

            threadCultureInfo.DateTimeFormat.ShortDatePattern = "MM/dd/yyyy";
            threadCultureInfo.DateTimeFormat.LongDatePattern = "MM/dd/yyyy hh:mm:ss tt";
            uiCultureInfo.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
            uiCultureInfo.DateTimeFormat.LongDatePattern = "dd/MM/yyyy hh:mm:ss tt";

            Thread.CurrentThread.CurrentCulture = threadCultureInfo;
            Thread.CurrentThread.CurrentUICulture = uiCultureInfo;

the grid that use the templates work properly but the view with the js stop working

Victor
Top achievements
Rank 1
 answered on 13 Jun 2016
5 answers
147 views

I have a scenario where I need a way for the user to cancel an insert once they have chose to insert a new row.

The configuration is InCell editing with a custom "save" button and a custom "add" on top of the view.  So the grid is in batch edit mode and is working fine other than when the user decides to insert a row.  If I place a default "Cancel" command that cancel button will be in every row.  That is one problem.

So I decided to have a hidden column at the end of the grid with a client template containing a "Cancel" button.

When they insert a new row I hook the onEdit event of the grid and make the column visible.  But in doing so all of the column widths get whacked out.  I searched a bit to find a resize row method but it is not working.

 

function resizeColumnDefaults() {
    debugger;
    resize(0, 250);
    resize(2, 100);
    resize(3, 100);
    resize(5, 100);
    resize(6, 100);
    resize(8, 120);
    resize(9, 300);
    resize(10, 75);
    resize(11, 75);
    resize(13, 75);
}
 
 
function resize(idx, width) {
    $("#Grid .k-grid-header-wrap") //header
       .find("colgroup col")
       .eq(idx)
       .css({ width: width });
 
    $("#Grid .k-grid-content") //content
       .find("colgroup col")
       .eq(idx)
       .css({ width: width });
}
 
 
function onEdit(e) {     
    var grid = $("#Grid").data("kendoGrid");
    grid.showColumn(11);
    resizeColumnDefaults();      
 
    }

 

Can someone offer a solution?

 

Thanks,

Reid

 

 

Galin
Telerik team
 answered on 13 Jun 2016
4 answers
681 views

Hi,

Whe I hide columns in a sub-grid I get problems with the look of the sub-grid. The reason seems to be that I hide the last column that does not have the width set (to make this column take up the remaining space in the row).

 

The template for the sub-grid from the cshtml page:

    <script id="utförseltemplate" type="text/x-kendo-tmpl">
        @(Html.Kendo().Grid<UtförselViewModel>()
              .Name("grid_#=Id#")
              .TableHtmlAttributes(new { @class = "ansokan-produkter-utforsel-subgrid" })
              .Columns(columns =>
              {
                  columns.Bound(p => p.Id).Hidden(true);
                  columns.Bound(p => p.UtförselDiarieNummer).Title("Diarienummer").Width(150);
                  columns.Bound(p => p.Datum).Format("{0:yyyy-MM-dd}").Title("Utförseldatum").Width(120);
                  columns.Bound(p => p.DelKvantitet).Title("Levererad kvantitet").Width(120);
                  columns.Bound(p => p.Enhet).Title("Enhet");
              })
              .Sortable()
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .Read(r => r.Action("ProduktUtförslarRead", "Giltiga", new { produktId = "#=ProduktId#", ansökanProduktId = "#=Id#" }))
                  .Sort(sort => sort.Add(r => r.Datum).Descending())
              )
              .Events(events => events.DataBound("UtforslarDataBound"))
              .ToClientTemplate()
        )
    </script>

Part of the javscript ondatabound:

    if (some condition) {
        this.hideColumn(3);
        this.hideColumn(4);
    }

When I hide this column the grid looks chopped off. I guess that I need to set the column width in the javascript, but I have not been able to figure out how.
Can you help me set the column width in the javascript or set the width of the whole sub-grid?

Best regards,

Henrik

Henrik
Top achievements
Rank 1
 answered on 13 Jun 2016
2 answers
508 views

I'm setting the value of a property using the following JavaScript code

var documentList = $("#documentsList").data("kendoListView");
var dataSource = documentList.dataSource;
var dataUid = documentList.select().attr("data-uid");
var item = dataSource.getByUid(dataUid);
var datepicker = $("#documentDate").data("kendoDatePicker");
 
item.set("DocumentDate", datepicker.value());
 
if (dataSource.hasChanges()) {
  dataSource.sync();
}

My controller is receiving the post when the datasource is synced and the other properties are being set. This is the C# of my controller

public JsonResult Update([DataSourceRequest]DataSourceRequest request, InboxDocument document)
{
   return Json(new[] {SharePointHelper.UpdateInboxDocument(HttpContext, document)}.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
 
}

All the other properties that are set are being sent through, but when I look at the request sent through in F12 tools, the following is displayed.

{DocumentDate: {errors: ["The value '6/21/2016 1:00:00 AM' is not valid for DocumentDate."]},…}

This is the same for any other date values.

 

 

Daniel
Telerik team
 answered on 13 Jun 2016
3 answers
1.3K+ views

I have two checkboxes in a Kendo MVC Grid row and need some understanding as to how to set the dataitem property when they are clicked.  I have been successful when there is one checkbox per row doing the following:

columns.Bound(p => p.bDelete).ClientTemplate("<input type='checkbox' name='bDelete' Id='bDelete' #= bDelete ? checked='checked': '' # class='chkbx'/>")
                         .Width(70).HtmlAttributes(new { style = "text-align: center", title = "Delete Selected" });

<script>
    // Any rows that get checked or unchecked after the form is loaded need
    // to pass though this event to get the underlying record reconciled
    $(function () {
 
 
        $('#Grid')
            .on('click',
                '.chkbx',
                function (e) {
                    debugger;
 
                    var checked = $(this).is(':checked');
                    var grid = $('#Grid').data().kendoGrid;
                    var dataItem = grid.dataItem($(this).closest('tr'));
                    // if we are in insert mode do not let the user check    the                delete checkbox
                    if (dataItem.iProjectSequence == 0) {
                        e.preventDefault();
                        dataItem.set('bDelete', false);                    return;
                    }
 
                    dataItem.set('bDelete', checked);
                    dataItem.set('bModified', true);
                    dataItem.set('dirty', true);
                    SetRowsModifiedState();
                    SetPageMessage("Data Modified");
                    $("#New").prop("disabled", true);
                    $("#Cancel").prop("disabled", false);
                });
    })
</script>

 

The code above works for a row that has only one checkbox in it.  How do I detect the underlying model value attached to the checkbox being clicked so that I can set *ONLY* that field?

 

Thanks

 

 

 

 

 

 

Konstantin Dikov
Telerik team
 answered on 13 Jun 2016
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
MultiColumnComboBox
Dialog
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
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?