Telerik Forums
UI for ASP.NET MVC Forum
2 answers
232 views

Hi,

 We're trying to use foreign key columns in the MVC grid and came to the realization it sorts on the numeric ID value rather than the foreign table text value. Telerik has mentioned there is no way for them to implement a fix, but our group was wondering if anyone else has come up with a work-around or simple fix to accomplish this.

Allan
Top achievements
Rank 1
 answered on 15 Nov 2017
3 answers
203 views

The asp-net mvc example shows how to load a spreadsheet and serialize it.

public class HomeController : Controller
{
    public ActionResult Read()
    {
        var path = Server.MapPath("~/App_Data/path/to/document.xlsx");
        var workbook = Telerik.Web.Spreadsheet.Workbook.Load(path);
        //Uses Newtonsoft.Json internally to serialize fields correctly.
        return Content(workbook.ToJson(), Telerik.Web.Spreadsheet.MimeTypes.JSON);
    }
}

 

Question:

What would the razor code look like to render the serialized workbook sent as the view model ?

Neli
Telerik team
 answered on 14 Nov 2017
1 answer
2.7K+ views

Hi,

I have a grid that contains this column (simplified for clarity):

columns.Bound(c => c.Status)
    .Filterable
    (
        f => f.Extra(false).Multi(true).CheckAll(true).BindTo
        (new[]
        {
                    new { Status = "New" },
                    new { Status = "Started" },
                    new { Status = "Completed" }
        })
    );

 

I want both "New" and "Started" to be checked by default when the page is first displayed.

In the DataSource, I have this code:

.DataSource
(
    .Filter
    (
        f => f
        .Add(x => x.Status).IsEqualTo("New")
    )
)

 

However, I cannot figure out how to add a second value, "Started", so that both are checked by default. How can I do this?

Thanks.

Viktor Tachev
Telerik team
 answered on 14 Nov 2017
3 answers
395 views
Has anyone had any luck with finding documentation on geolocation when using the bing layer on the kendo map UI ?  I can't seem to find any documentation.   Basically I am wanting to take advantage of the built in location services now in html 5 using mvc as my framework.
Stamo Gochev
Telerik team
 answered on 14 Nov 2017
1 answer
168 views

Hi,

I'm using

@{ var culture = System.Globalization.CultureInfo.CurrentCulture.ToString(); }
    <script src="@Url.Content("~/Scripts/cultures/kendo.culture." + culture + ".min.js")"></script>
    <script> kendo.culture("@culture")  </script>

and the most of the clients are using nl-NL as their culture and this works like I would expect but:

The official locale tells us the decimal separator is "," and thousand separator "." but everybody wants to use decimal separator "." and thousand separator ",".

Is it possible to change the kendo.culture.nl-NL.min.js file (or do I need to change kendo.culture.nl.min.js) to make this change?

 

Thanks,

Maurice Lucas


Neli
Telerik team
 answered on 13 Nov 2017
1 answer
136 views

Hi,

I have a spreadsheet in which I am populating the values using a dataset and datatable.

Once the user modifies the values in the spreadsheet, i want to pick that row and pass it to a datatable so that I can perform my update operation.

transport: {
        /* the other CRUD settings are ommitted for brevity */
        update:

 

Can you let me know how to pass the modified row to dataset or datatable using the transport method?

Veselin Tsvetanov
Telerik team
 answered on 13 Nov 2017
1 answer
144 views

Hi

I am loading a spreadsheet with the help of a dataset result. I have a stored procedure that output's the result to a dataset and this dataset is being loaded to a datatable and rendered on the speadsheet using datasource. Below is my code

public ActionResult Products_Load([DataSourceRequest]DataSourceRequest request)
        {
            DataTable dt = new DataTable();
            dt.Clear();
 
            DataSet dsGetData = HandlerUtilities.HandlerFunctions.GetDynamicSheetData(1, 4);
            if (dsGetData != null)
            {
                dt = dsGetData.Tables[0];
            }
 
            dt.Columns.Remove("atUserid");
            dt.Columns.Remove("atTimestamp");
            dt.AcceptChanges();
 
            DataSourceResult result = dt.ToDataSourceResult(request);
            JsonResult oJsonResult = Json(result, JsonRequestBehavior.AllowGet);
            return oJsonResult;
        }

 

When the data is rendered on the spreadsheet, the datetime values are getting converted into /Date(xxxxxx)/ instead of original values. I have attached the screenshot of my output for reference. My dataset is dynamic and everytime it will get changed and due to this I am not using a view model to bind the data.  Hence, I cant provide the fieldname and its format in the client side as I dont know what the fieldnames will be. Is there any workaround fr this?

Veselin Tsvetanov
Telerik team
 answered on 13 Nov 2017
3 answers
497 views

I'm building a Grid that lists a collection of data that comes from multiple sources. One of those sources is a web service so it's possible that the web service call might fail. If it does, I still want to display the data from the other sources, but I want to display a warning on the page that the web service data is not included in the results. I have a ViewModel containing this property:

public class MyVM
{
    public bool ServiceUnavailable { get; set; }
    public List<RowVM> GridData { get; set; }
}

 

So I could show the warning when the Grid first loads. However, I'm not actually going to populate GridData during the initial page load. I want the Grid to make an AJAX call to load the first page (and for any other paging.) So after each Read action completes, I need to check if ServiceUnavailable and display the warning if it is true. The problem is, the Read action only returns a List<RowVM>.ToDataSourceResult(). How can I return additional data that is separate from the Grid row data? Is there a way to override the client-side Read function to make my own AJAX call and then on success update the datasource with the returned data myself?

 

 

 

Konstantin Dikov
Telerik team
 answered on 13 Nov 2017
3 answers
546 views

Below is my autocomplete code. If I uncomment the Events section above the span class 'k-widget k-autocomplete k-header k-state-default' is removed, and the Kendo autocomplete is stoped and it is like a simple text box. Autocomplete functionality will be no more and no events are fired. Please let me know how should I fix the issue, and what may be reason for the same.

<style>

        .imgslt .k-autocomplete {
            width: 25% !important;
        }
    </style>

  

<div class="form-group imgslt">
            <label>Select Image:</label>
            <div class="demo-section k-content">
                @(Html.Kendo().AutoComplete()
          .Name("ImageNameList")
          .DataTextField("imageName")
          .Filter("contains")
          .MinLength(2)
          .HtmlAttributes(new { style = "width:100%" })
          //.Events(e => e
          //      .Select("autocomplete_select")
          //      .Change("autocomplete_change")
          //  )
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetListImages", "Assessment");
                  //.Data("onAdditionalData");
              })
              .ServerFiltering(false);
          })
 
                )
            </div>
 
<script>
 
     function autocomplete_select() {
                //Handle the select event.
      alert('select');
            }
 
            function autocomplete_change() {
                //Handle the change event.
    alert('change');
            }
 
</script>
Ivan Danchev
Telerik team
 answered on 13 Nov 2017
7 answers
1.4K+ views

 We have a heavy traffic data in DB, we don't want to dump huge data on to the client side and do grouping and aggregating.

So I started doing it on server side pagination, grouping and stuck with one column grouping. Need help with support multiple column grouping and then also able to aggregate data on server side.

Here is my grid Read Method

[AcceptVerbs(HttpVerbs.Post)]
       public ActionResult Read_Traffic([DataSourceRequest] DataSourceRequest request)
       {
           var results = _auditService.All(OperatingUser.CompanyId, request, out int totalRecords);
           if (request.Groups != null && request.Groups.Any())
           {
               //HaBo: Currently supporting only single grouping.
               //need to work on to support multiple groupings.
               return Json(new DataSourceResult
               {
                   Data = CustomGroupBy(results, request.Groups[0].Member),
                   Total = totalRecords
               });
           }
           //List<object> returnData = results.Cast<object>().ToList();
           //foreach (var groupDescriptor in request.Groups)
           //{
           //    returnData = (List<object>) CustomGroupBy(results, groupDescriptor.Member);
           //}
           return Json(new DataSourceResult
           {
               Data = results,
               Total = totalRecords // Total number of records
           });
       }

 

Here is my Grouping Method

private static IEnumerable<object> CustomGroupBy(List<Audit> results, string groupKey)
       {
           switch (groupKey)
           {
               case "SessionId":
                   return results.GroupBy(x => x.SessionId).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "SessionId", Subgroups = new object[] { }, Items = g });
               case "AuditId":
                   return results.GroupBy(x => x.AuditId).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "AuditId", Subgroups = new object[] { }, Items = g });
               case "UserName":
                   return results.GroupBy(x => x.UserName).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "UserName", Subgroups = new object[] { }, Items = g });
               case "IpAddress":
                   return results.GroupBy(x => x.IpAddress).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "IpAddress", Subgroups = new object[] { }, Items = g });
               case "UrlReferrer":
                   return results.GroupBy(x => x.UrlReferrer).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "UrlReferrer", Subgroups = new object[] { }, Items = g });
               case "TimeAccessed":
                   return results.GroupBy(x => x.TimeAccessed).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "TimeAccessed", Subgroups = new object[] { }, Items = g });
               case "CountryName":
                   return results.GroupBy(x => x.CountryName).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "CountryName", Subgroups = new object[] { }, Items = g });
               case "CountryCode":
                   return results.GroupBy(x => x.CountryCode).Select(g =>
                       new { Aggregates = new { }, Key = g.Key, HasSubgroups = false, Member = "CountryCode", Subgroups = new object[] { }, Items = g });
           }
           return null;
       }

 

As you can notice currently I am only able to group with the first group member, how can I support multiple column grouping?

Tsvetina
Telerik team
 answered on 10 Nov 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?