Telerik Forums
UI for ASP.NET MVC Forum
6 answers
2.4K+ views

Hi,

I would like to have a button on toolbar in grid and then by clicking on the button the pup up appears. Then It provides opportunity to add new raw in the grid (insert information in sql server). I am not sure which ways are better, using 1.toolbar.Create() or 2.toolbar.custom()?

1. if I use toolbar.Create().Text("default add"), I have Create(create => create.Action("AddNewSample", "MyController", new { model = "#=MyModel#" })) in DataSource.

Then, I have the popup, but I don't know how I can add information through Update button. It seems it does not call the function in controller.

here is my controller:

public ActionResult AddNewSample(long? A, string B, string C, DateTime D)
        {
            if (ModelState.IsValid)
            {
                db.Sp_Sample_Ins(A, B, C, D);
             } 

            return View("Index");
        }

 

2. But If I use toolbar.Custom(), I should create pop up window myself. so I have toolbar.Custom().Text("Add New Sample").HtmlAttributes(new { id = "customCommand" });

and in JavaScript I tried to follow this:

http://demos.telerik.com/aspnet-mvc/grid/custom-command

Preferably, I would like to have a template in another page(not on my Grid's page).

but I dose not work.

I appreciate any suggestion and help.

 

Stefan
Telerik team
 answered on 03 Oct 2017
3 answers
262 views

When using this code from the server import/export demo, hidden rows get expanded to the default width, while using the frontend excel export preserves the row height

[HttpPost]
        public ActionResult Download(string data, string extension)
        {
            var workbook = Workbook.FromJson(data);
            using (var stream = new MemoryStream())
            {
                workbook.Save(stream, extension);
 
                var mimeType = Telerik.Web.Spreadsheet.MimeTypes.ByExtension[extension];
                return File(stream.ToArray(), mimeType, "Exported" + extension);
            }
        }
Joana
Telerik team
 answered on 02 Oct 2017
3 answers
734 views

We just upgraded to the latest 2017.3.913 to fix an issue where we couldn't get a good PDF export (AllPages() wasn't working) from a grid with server paging.  That problem was corrected with the update but now we have another PDF export issue.  We have a grid that has row detail grids and is NOT using server side paging.  When the user clicks export, we use the PDF export event to expand all of the detail grids and change the number of rows per page to a large number so that all records will be exported along with the row details.

function onPdfExport(e) {     

    var grid = e.sender;     

    var pageSize = grid.dataSource.pageSize();     

    grid.dataSource.pageSize(5000);     

    grid.refresh();     

    grid.expandRow(this.tbody.find("tr.k-master-row"));     

   e.promise         

        .done(function () {             grid.dataSource.pageSize(pageSize);             grid.refresh();         });

}

The problem we're having happens whether we are using this code to expand all rows OR if we comment out the code and expand a few manually.  If I expand 3 rows, the export is combining the details for each row and showing the detail data for all open rows in all open rows.  I know that is a little difficult to understand...if each of the 3 rows that have been expanded have 1 detail row each then 3 detail rows will export under every expanded row.  See attached images for a clearer description.  These images were generated without the use of the PDF export event handler defined above.  I manually expanded 3 rows before exporting.  The first screenshot is the actual grid showing 3 rows expanded.  The second is the page from the PDF export where you can see that the detail grids are combined.

 

 

Konstantin Dikov
Telerik team
 answered on 02 Oct 2017
3 answers
94 views

I have a grid that I am loading with a linq query to my database.  On page load it works great and returns dated now + 21 days.  The users need to ability to then enter there own dates to search between.  It is all working great right up to the point the data returned from the controller needs to get into the grid.  It just won't load.

Relevent code of grid

.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(20)
    .Read(read => read
        .Action("Action", "Controller")
        )
    .Sort(sort =>
    {
        sort.Add(p => p.ID).Ascending();
        sort.Add(p => p.Date).Ascending();
    })
    .Group(g =>
    {
        g.Add(c => c.ID);
    })
    .ServerOperation(false)
)

 

When the user enters 2 dates and clicks search the function is run.  The grid is cleared and a loading message appears goes away and the grid remains blank.

function onClickSearch() {
    var fromDate = $("#startDate").data("kendoDatePicker").value(),
        toDate = $("#endDate").data("kendoDatePicker").value();
    $("#prodReadiGrid").data("kendoGrid").dataSource.read({ "start": fromDate, "end": toDate});
}

 

When I debug I see the controller sending the view the grid, it just does not load.

 

Any ideas?

Georgi
Telerik team
 answered on 02 Oct 2017
4 answers
1.0K+ views

Hi,

MultiSelect Tag Template selected value with comma separate in input field.

Is it available in document? If not could you send sample code how to set selected value with comma separate.

Regards
Suman

 

Suman
Top achievements
Rank 1
 answered on 01 Oct 2017
2 answers
870 views

I am able to populate Editor programmatically from my model using Alexander's code snippet from http://www.telerik.com/forums/how-do-i-set-the-value-to-a-model-value-in-a-template-7d3339946e0d.

However, when I try to populate editor using an Ajax call (based on a selection in a dropdownlist), then it stops working.  I can see the correct values are being returned and my other bound fields are populating correctly, just not the Editor textarea.

My editor:

@(Html.Kendo().EditorFor(m => m.Content)
      .Name("Content")
      .HtmlAttributes(new { style = "height:650px", aria_label = "editor" })
 )

and my Jquery:

$(function () {
        $('#Name').change(function () {
            var name = $(this).val();
 
            var success = function (results) {
                debugger;
                $('#Id').val(results.Id);
                $('#Name').val(results.Name);
                $('#NewName').val(results.Name);
                $('#Content').val(results.Content);
            };
 
            $.ajax({
                url: '/Staff/Email/GetEmail',
                type: 'POST',
                data: {
                    name: name
                },
                dataType: 'json',
                success: success
            });
        });
    });

 

The textarea has an id of 'Content', so why can't I set it's value using Jquery?

 

Thank you in advance,

Laura

Laura
Top achievements
Rank 1
 answered on 29 Sep 2017
3 answers
204 views

Maybe I am missing documentation if such a feature exists but is it possible to display some kind of indication on a column header to identify that particular column has an active filter?

When sorting a column it can display an up arrow or down arrow which indicates active sorting on that column. Is there an equivalent for active filter?

 

Erik
Top achievements
Rank 1
 answered on 29 Sep 2017
2 answers
6.6K+ views
Hello,
I am looking for information on how to add a dropdown box to an MVC specific grid control. I need the box to display in a cell and show when the grid is rendered. Do you know of a sample or have example code available?

Thanks 
Viktor Tachev
Telerik team
 answered on 29 Sep 2017
1 answer
831 views

Hi, I'm trying to get this: http://demos.telerik.com/aspnet-mvc/grid/detailtemplate

except I don't need the tabstrip. So what I want is just the grid. Is that possible because when I try to do this with just a grid, I get an empty row with no data.

Thanks,
Jokull

Georgi
Telerik team
 answered on 29 Sep 2017
4 answers
302 views

Hi, I am trying to customize my mvc grid, here is the image https://ufile.io/6c1xf

1. No header, the columns.bound to customize instead of c.name

2. How to put edit and delete into 1 column?

3. How to call javascipt in string not integer?

 


@(Html.Kendo().Grid<iOneDistribution.Web.Models.Users.UserViewModel>()
      .Name("grid")
      .Columns(columns =>
      {

           //1. header must be able to customize.

           //3.  it doesn't call the datagrid as this must be in string not integer
           columns.Bound(c =>
             c.Name).ClientTemplate(
                      "<a style='cursor:pointer' onclick='getEditView('#=UserCode#');' " +
            ">EDIT</a>").Width("90");

         //  2. it is in the other column, i want to put into 1 column with the edit

         columns.Command(command =>
          {
              command.Destroy().Text(" ");
          }).Width(100);
          columns.Bound(c => c.Name);
          columns.Bound(c => c.Email);
          columns.Bound(c => c.MobilePhone);
          columns.Bound(c => c.OfficePhone);
          columns.Bound(c => c.HomePhone);
          columns.Bound(c => c.UserPosition);
          columns.Bound(c => c.IsSalesPerson);
          columns.Bound(c => c.IsPurchaser);
          columns.Bound(c => c.IsActive);
          columns.Bound(c => c.IsAllowApprove);
          columns.Bound(c => c.DefaultCulture);
      })
      .Pageable()
      .Sortable()
      .Filterable()
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(20)
          .Model(model => model.Id(u => u.UserCode))
          .Read(read => read.Action("Users_Read", "Users"))
          .Destroy(update => update.Action("Destroy", "Users"))
      )
)

<script type="text/javascript">
    function getEditView(id) {
        alert(id);
        $.post("@Url.Action("ShowEdit", "Users")", {id: id}, function(data) {
            if (data) {
                $('#EditDiv').append(data);
            }
        });
    }
</script>
Stefan
Telerik team
 answered on 29 Sep 2017
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?