We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Unable to determine the groupIndex on a mobile device

Hi,
I've had to come up with my own implementation logic to determine the groupIndex for an event (target isn't always available depending on how the appointment is generated). This has been working well, but for some reason getGroupIndexFromEvent returns 0 on mobile devices.

My full code for the groupIndex, e.g. in the popupOpen event:

            var groupIndex = 0;
            if (hasOwnProperty(args.data, "groupIndex")) {
                groupIndex = args.data.groupIndex;
            } else {
                if (Array.isArray(args.data.ResourceId)) {
                    // this is were it fails on mobiles:
                    let testObject = {
                        ResourceGroupId: args.data.ResourceGroupId,
                        ResourceId: args.data.ResourceId[0]
                    };
                    console.log(testObject);
                    // on a desktop computer browser: {ResourceGroupId: "1", ResourceId: "11"}
                    // on a mobile device:  {ResourceGroupId: "1", ResourceId: "11"}
                    groupIndex = this.eventBase.getGroupIndexFromEvent({
                        ResourceGroupId: args.data.ResourceGroupId,
                        ResourceId: args.data.ResourceId[0]
                    });
                    // on a desktop browser: (int) 1
                    // on a mobile browser: (int) 0
                    
                } else {
                    groupIndex = this.eventBase.getGroupIndexFromEvent(args.data);
                }
            }
            if (groupIndex === 0) console.error("Unable to determine the groupIndex");

This is pretty weird - would you have any idea why this should yield different results based on whether the exact same software is run on e.g. Chrome/Firefox versus e.g. a Galaxy S5 or an Iphone?

8 Replies

VD Vinitha Devi Murugan Syncfusion Team April 11, 2019 12:29 PM UTC

Hi Stefan, 
  
Greetings from Syncfusion.  
  
We have prepared the below sample to log the groupIndex value using popupOpen event.  
 
 
 popupOpen="onPopupOpen" 
 
<script type="text/javascript"> 
    function onPopupOpen(args) { 
        var groupIndex = args.target.getAttribute("data-group-index"); 
        console.log("Group Index: "+ groupIndex); 
    } 
</script> 
 
Regards, 
M.Vinitha devi. 



ST Stefan April 11, 2019 01:39 PM UTC

Hi Vinith

args.target does not always exist (e.g. when opening the editor window programmatically with event data), which is why I had to find alternative solutions to reliably obtain the group index.

My solution works fine on a desktop browser, but it fails on mobile devices. For some reason
(scheduler).eventBase.getGroupIndexFromEvent(object) returns the correct groupIndex on a mobile browser, but 0 on a phone.

This has been tested with identical objects - I can prepare a stackblitz example if you wish. This looks very much like a bug.



KK Karthigeyan Krishnamurthi Syncfusion Team April 12, 2019 11:37 AM UTC

Hi Stefan,  
 
Thanks for your update. 
 
We have prepared the sample with the provided code example and able to retrieve the group index both in mobile browser and mobile. Please share your sample / modify our sample to replicate the issue and revert to proceed further. 
 
Regards, 
Karthi 
 



ST Stefan April 13, 2019 12:52 PM UTC

Please retry it with this slightly modified sample, events are now displayed in TimeLine view. This now exhibits the same behaviour, where the groupIndex cannot be determined when in mobile view.
https://scheduler-groupindex.stackblitz.io
https://stackblitz.com/edit/scheduler-groupindex?file=index.js

Please also note that I am unable to rely on args.target - this is not always available! (e.g. when opening the editor window programmatically). Given that getGroupIndexFromEvent really only requires these fields, there shouldn't be any reason for that they don't return the same data whether opened on a browser or mobile.


ProjectId: args.data.ProjectId,
TaskId: args.data.TaskId[0]


ST Stefan April 13, 2019 01:06 PM UTC

Actually, I've just tried the same test with your original sample. The behaviour is identical.

Whilst in desktop view, the groupIndex is determined correctly every time. Whilst in Mobile view, I receive the same error. Console output:
{ ProjectId: 1, TaskId: 1, __proto__: Object }
index.js:38 Unable to determine the groupIndex
index.js:40 Group Index: 0

Of course in mobile view only one resource is visible at a time - might that be related to the issue?


ST Stefan April 13, 2019 01:09 PM UTC



ST Stefan April 13, 2019 04:54 PM UTC

I found the error of my ways, and only wish this was described somewhere in the documentation. I had wrongfully assumed that the groupIndex is constant, but it turns out that where in TimeLineView the resource I was after is 1, in mobile views it is 0.

So changing my code to initialise groupIndex as -1 and testing against that works fine - so far.

The next issue waited just around the corner. Upon booking, I usually retrieve a few settings stored within the resource, such as name or capacity.
For this I can access 

getScheduleObject().resourceBase.renderedResources[groupIndex].resourceData.Text;

The property renderedResources does not exist on a mobile browser though. Any reason why?

EDIT: Never mind, I've seen in the source that it is virtually identical to lastResourceLevel (this.renderedResources = this.lastResourceLevel;) which appears to be always available. SyncFusion is still not making this easy by exposing different properties in different views - but maybe there's a good reason to do this that I don't understand.

In any case, I would like to say thank you once again for outstanding support - I do apologise for wasting your time when I didn't realise that the groupIndex changes from view to view.


KK Karthigeyan Krishnamurthi Syncfusion Team April 15, 2019 06:32 AM UTC

Hi Stefan, 
 
We are happy that you found the solution. 
 
The renderedResources is internally used only for virtual scrolling case, and lastResourceLevel is common variable for all cases. 
 
Regards, 
Karthi 
 


Loader.
Live Chat Icon For mobile
Up arrow icon