EasyUI Forum
November 30, 2025, 05:22:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Can we use formatter of Easyui Calendar to display custom date  (Read 7554 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« on: April 09, 2019, 02:06:48 PM »

I am trying to format date to show event and status from remote json file but could not get it working:

var remotejson = {
   "id":[{
      "d":5,
      "m":4,
      "y":2019,
      "status":"P",
      "color":"teal"
   },{
      "d":12,
      "m":4,
      "y":2019,
      "status":"H",
      "color":"blue"
   }]
};
$.each(remotejson.id, function(i, item) {
       var jd = json.id.d;
       var jm = json.id.m;
       var jy = json.id.y;
       var jc = json.id.color;
       var js = json.id.status;
  });
   $('#atcalendar').calendar({
   formatter: function(date){
      var m = date.getMonth();
      var d = date.getDate();
      var y = date.getFullYear();
                var opts = $(this).calendar('options');
      if(opts.d==jd && opts.m==jm && opts.y==jy){
         return '<div style="color:'+jc+'">' + d + '<br>'+jdate.status+'</div>';
          } else {
                   return d;
              }      
   },
   onSelect: function(date){
            //show another dialog
   },
       onNavigate:function(year,month,date){
          //load fresh data from php which generates the json
       }
});

If I put the each loop inside the formatter, the calendar date also gets looping. With the above code, no date is shown on the calendar. I am trying to put the above code on easyui dialog onLoad:function(). I want to style and show custom text along with the date, and when I click and the calendar navigation, I want fresh data from remote json generated by php. Is this possible in easyui calendar? If it is possible to achieve, please help.

Thanks and regards,
Alfred
Logged
jarry
Administrator
Hero Member
*****
Posts: 2302


View Profile Email
« Reply #1 on: April 10, 2019, 12:03:56 AM »

Please look at this example http://code.reloado.com/otukur/edit#preview
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!