Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:30:02+00:00 2026-06-18T10:30:02+00:00

I want to display Text for my ForigenKey columns instead of numeric values. There

  • 0

I want to display Text for my ForigenKey columns instead of numeric values. There are a lot of examples to retrieve TextMember by comparing ID but they are not working in my case. I just started to use Kendo ui so dont know much about it

Here is the code :

$(document).ready(function () {

 dataSource1 = new kendo.data.DataSource({

        transport: {
              read:  {
               url: "Data/AttendanceCode/GridSelect.php",
                dataType: "json",

                            },

                update: {
                   url: "Data/AttendanceCode/GridUpdate.php",
        dataType: "json",
                        type:"GET"
            },

                  destroy: {
                     url: "Data/AttendanceCode/GridDelete.php",
                      dataType: "json",
          type:"POST"
                            },

                    create: {
                      url: "Data/AttendanceCode/GridInsert.php",
                        dataType: "json",
              type:"POST"
                            },

                        },

                  schema: {
         data: "data",

                       model: {
                          id: "AttendenceID",

                           fields: {
                              AttendenceID : { editable: false, nullable: true },
                              TeacherID: { field: "TeacherID", defaultValue: "EIIT0002" },
                                }
                            }
                        },


                    });



$("#grid").kendoGrid({
           dataSource: dataSource1,

    pageSize: 10,
            pageable: {
                refresh: true,
                pageSizes: true
                    },
                    editable:{ mode : "popup" },
                    height: 400,
        filterable: true,
                    columnMenu: true,
        sortable: true, 
                    reorderable: true,
                    resizable: true,
                    toolbar: ["create"],

                    columns: [
                       { field:"AttendenceID", title: "Attendence ID", width:"130px" },

                       { field: "TeacherID", title:"Teacher", width: "100px" , editor: TeacherDropDownEditor, template: "#=getTeacherName(TeacherID)#" },

                   { command: ["edit", "destroy"], title: "Action", width: "210px" }],

                });


            });

Teacher DropDown DataSource

teacher = new kendo.data.DataSource({

       transport: {
         read: {
    url : "Data/Teacher.php",
    dataType: "json" }
               },

    schema: {
    data : "Teacher"
         }

    }); 

// Teacher Editor

 function TeacherDropDownEditor(container, options) {
   $('<input data-bind="value:' + options.field + '"/>')
.appendTo(container)
     .kendoDropDownList({         
     dataTextField: "TeacherName",
dataValueField: "Service_NO",
 dataSource: teacher
     });
}   

Different approaches i found and tried to Get Teacher Name

1 –

  function getTeacherName(value) {

          var text = "";
     $.each(teacher, function () {
           if (this.Service_NO == value) {
            text = this.Name;
             return false;
           }
        });
     return text;
                      }

2 –

function getTeacherName(teacherID) {

 for (var idx = 0, length = teacher.length; idx < length; idx++) 
   {
    if (teacher[idx].Service_NO === teacherID) 
       {t = teacher[idx].Name;} 
    }                   
return t; 
    }

3 –

function getTeacherName(teacherID) {
      $.each(teacher, function(key, val) {
        if(val.Service_NO == tID){
           t = val.Name;
            }
             });
           return t;
            } 

It seems like dataSource (teacher) is not having any value.
PHP code is working perfectly.
Please Help if you have any idea whats wrong with my code.

Thanks !!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:30:03+00:00Added an answer on June 18, 2026 at 10:30 am

    You are right, teacher DataSource does not have any data because you are defining how to get the data (that’s what you do with the DataSource) but you are not reading it.

    Add:

    teacher.read();
    

    for manually forcing the data read.

    NOTE: This is something that happens magically when you have a Grid, ListView,… because these widget do it for you but this time, for displaying your grid you need to read it in advance since it is invoked from a JavaScript function (KendoUI grid code doesn’t know anything about what you have in the function getTeacherName other than the name).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a very large text file but want to break it
I want to display some text from server, but till then I want to
In edittext the text is coming leftmost corner. but i want to display the
I have navigation bar controller in which i want to display text. But the
i want to display text on my window and a next button ,but when
I want to display a text to user to inform that there is no
I want to display a text with a lot of lines. I added a
I want my UILabel display text from SQLite database. But it doesn't recognize new-line
I have the password field on page. I want to display text Enter password
I want to display some text on twitter/facebook when a link is clicked on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.