This is a migrated thread and some comments may be shown as answers.

sort field in jquery

6 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
alireza
Top achievements
Rank 1
alireza asked on 28 Nov 2012, 11:06 AM
i have filed the name material  that  in database ,table this field  3 value 1 or 2 or 3
i when data from webservice  send to datasource grid . two filed for material send. 1.materailId ,2.materialName
now want materailName display  and materalid for sort . ??
i want  when  onclick materailName  sort field  materialid ??

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Nov 2012, 08:28 AM
Hello,

 We don't understand what you are asking. If you need our assistance please elaborate what the problem is. Sending some code and or screenshots would definitely help. More info can be found here.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
alireza
Top achievements
Rank 1
answered on 29 Nov 2012, 10:05 AM
my design code
$(document).ready(function () {
 
                  var tdata = {};
                  tdata.filter = {};
                  tdata.filter.Payment = {};
                  tdata.filter.PageIndex = 10;
                  tdata.filter.PageSize = 100;
            
                  $("#grid2").kendoGrid({
 
                      height: 250,
                      sortable:{
                          info: true
                      },
                      filterable: true,
                      columnMenu: true,
                      pageable: {
                          info: true
                      }, // enable paging
                      columns: [
 
                         { field: "PPeriod", title: "period",  filterable: false, sortable: false },
                         { field: "PSchoolName", index: 'PSchoolid', title: "school name ", sortable: true }
 
                      ],
 
 
                      dataSource: {
                          serverPaging: true,
                          serverSorting: true,
                          serverFiltering: true,
                          pageSize: 500,
                          sortable: true,
                          filterable: true,
                          pageable: true,
                          pageable: {
                              refresh: true,
                              pageSizes: true
                          },
                          schema: {
                              data: "d.Data",
                              total: "d.Total", // ASMX services return JSON in the following format { "d": <result> }. Specify how to get the result.
                              model: { // define the model of the data source. Required for validation and property types.
                                  fields: {
                                      PPeriod: { type: "string"},
                                      PSchoolName: { type: "string"}
                                  }
                              }
                          },
                          transport: {
                              read: { type: "POST",
                                  url: "/WebService/Paymentsell.asmx/ReadSell",
                                  contentType: "application/json; charset=utf-8",
                                  dataType: "json",
                                  data: tdata
                              },
                              parameterMap: function (options) {
                                  if (options.sort != undefined) {
                                      if (options.sort[0] != undefined) {
                                          options.filter.OrderBy = options.sort[0].field;
                                          options.filter.Order = options.sort[0].dir;
                                      }
                                  }
 
                                  options.filter.PageIndex = options.page;
                                  return kendo.stringify(options); // kendo.stringify serializes to JSON string
                              }
 
                          }
                      }
                  });
in output webservice  . pperiod - schoolname - schoolid

i want user when want sort by schoolname .sort by schoolid do.
?
if options.sort[0].field == "schoolname"
options.sort[0].field="schoolid";
i want this work  do in bellow :
field: "PSchoolName", index: 'PSchoolid'
index for sort ?

columns: [
 
                         { field: "PPeriod", title: "period",  filterable: false, sortable: false },
                         { field: "PSchoolName", index: 'PSchoolid', title: "school name ", sortable: true }
 
                      ],

0
Atanas Korchev
Telerik team
answered on 29 Nov 2012, 10:55 AM
Hello,

 It seems that you have enabled serverSorting. In this case the actual sorting is not performed by Kendo UI but by the developer. This means that you should implement sorting by all fields necessary in your code (the web service method).

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
alireza
Top achievements
Rank 1
answered on 29 Nov 2012, 11:31 AM
This means havenot parametrs for sort field .for exampale.
field: "PSchoolName", index: 'PSchoolid'
field for display and index for sort .
other plugin have items index for sort field.
??
0
Accepted
Atanas Korchev
Telerik team
answered on 29 Nov 2012, 12:03 PM
Hi,

 If you just need to display a different field use the template of the column:

columns: [
{
     field: "field1", //  is used for sorting, filtering etc
     template: "#= field2 #" // used for display
}
]

Greetings,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
alireza
Top achievements
Rank 1
answered on 29 Nov 2012, 12:12 PM
resolve this problem .
thanks
Tags
Grid
Asked by
alireza
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
alireza
Top achievements
Rank 1
Share this question
or