Luciano França Posted May 22, 2023 Share Posted May 22, 2023 Create Component at runtime with "Ajax Error" is not a function What's wrong with this code ? Error O13._setBGColor is not a function procedure TMainForm.UniCalendarPanel1DayClick(Sender: TUniCalendarPanel; ADate: TDateTime; Allday: Boolean); Var vData: String; begin vData := FormatDatetime('yyyy-mm-dd', ADate); Sender.JSInterface.JSCall('_setBGColor', [vData]); end; procedure TMainForm.UniFormCreate(Sender: TObject); begin UniCalendarPanel1 := TUniCalendarPanel.Create(Self); UniCalendarPanel1.Parent := Self; UniCalendarPanel1.OnDayClick := UniCalendarPanel1DayClick; With UniCalendarPanel1 do Begin ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config) {' + 'sender._setBGColor = function(aData) {' + 'sender.el.select(''.x-calendar-weeks-cell'').elements.forEach(function(el) { if (el.style["background-color"] == "lightgray") { el.style["background-color"]=""} } ); ' + ' dataEl = sender.el.select(''.x-calendar-weeks-cell[data-date="'' + aData + ''"]''); ' + ' if (dataEl.elements[0]) { dataEl.elements[0].style[''background-color'']="lightgray" }' + '}}'; ClientEvents.ExtEvents.Values['calendarStore.load'] := 'function calendarStore.load(sender, records, successful, operation, eOpts) {' + 'Ext.defer(function(aData){' + JSName + '._setBGColor}, 500); }'; End; end; Function Unigui.7z Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 22, 2023 Share Posted May 22, 2023 1 hour ago, Luciano França said: What's wrong with this code ? Assign a Name to the component. Quote Link to comment Share on other sites More sharing options...
Luciano França Posted May 22, 2023 Author Share Posted May 22, 2023 37 minutes ago, Sherzod said: Assign a Name to the component. Much obliged. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.