iOS tests fails in Release but works in Debug - detox

I just did a small set of tests for my react-native app and they work well when testing in iOS - Debug mode. But when I try to run it in iOS - Release it just fails, saying can't find the components.
I know more information is needed but I have no idea how to actually move forward.
Notes:
- All testID are in <View />
- I tried to run with simulator open and the app actually opens
- Did trace and it has no much useful data (but the hierarchy shows no accessibilityID or testID)
Follows the hierarchy:
Cannot find UI Element.
Exception with Assertion: {
"Assertion Criteria": "assertWithMatcher:matcherForSufficientlyVisible(>=0.750000)",
"Element Matcher": "((!(kindOfClass('RCTScrollView')) && (respondsToSelector(accessibilityIdentifier) && accessibilityID('WelcomeScreen_Contents'))) || (((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches(kindOfClass('RCTScrollView'))) && ((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && parentThatMatches((respondsToSelector(accessibilityIdentifier) && accessibilityID('WelcomeScreen_Contents'))))))",
"Recovery Suggestion": "Check if the element exists in the UI hierarchy printed below. If it exists, adjust the matcher so that it accurately matches element."
}
Error Trace: [
{
"Description": "Interaction cannot continue because the desired element was not found.",
"Error Domain": "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code": "0",
"File Name": "GREYElementInteraction.m",
"Function Name": "-[GREYElementInteraction matchedElementsWithTimeout:error:]",
"Line": "124"
}
]
Hierarchy: <UIWindow:0x7fb2a5622f30; AX=N; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
|--<RCTRootView:0x7fb2a5620e70; AX=N; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| |--<RCTRootContentView:0x7fb2a57c5200; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | |--<RCTView:0x7fb2a558c7a0; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | |--<RCTView:0x7fb2a55baaf0; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | |--<RCTView:0x7fb2a55a6f50; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | |--<RCTView:0x7fb2a5517b40; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | |--<RCTView:0x7fb2a5791380; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | |--<RCTView:0x7fb2a5791070; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | |--<RCTView:0x7fb2a5790d60; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | | |--<RCTView:0x7fb2a5790a50; AX=N; AX.frame={{0, 0}, {414, 88}}; AX.activationPoint={207, 44}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 88}}; opaque; alpha=1>
| | | | | | | | | | |--<RCTView:0x7fb2a5790740; AX=N; AX.frame={{-414, 0}, {414, 88}}; AX.activationPoint={-207, 44}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{-414, 0}, {414, 88}}; opaque; alpha=1>
| | | | | | | | | | | |--<RCTView:0x7fb2a579d570; AX=N; AX.frame={{-414, 0}, {414, 88}}; AX.activationPoint={-207, 44}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 88}}; opaque; alpha=1>
| | | | | | | | | | | | |--<RCTView:0x7fb2a579d260; AX=N; AX.frame={{-414, 44}, {414, 43.5}}; AX.activationPoint={-207, 65.75}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 44}, {414, 43.5}}; opaque; alpha=1>
| | | | | | | | | |--<RCTView:0x7fb2a578a1b0; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | | | |--<RCTView:0x7fb2a5593d10; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | | | | |--<RCTView:0x7fb2a55a5c90; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | | | | | |--<RCTView:0x7fb2a55d0c60; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 0}, {414, 896}}; AX.activationPoint={207, 448}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 896}}; opaque; alpha=1>
| | | | | | | | | | | | | |--<RCTView:0x7fb2a55d92f0; AX=N; AX.label='Welcome! Let's go! Sign in'; AX.frame={{0, 44}, {414, 818}}; AX.activationPoint={207, 453}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 44}, {414, 818}}; opaque; alpha=1>
| | | | | | | | | | | | | | |--<RCTView:0x7fb2a55d0950; AX=N; AX.label='Sign in'; AX.frame={{0, 816}, {414, 36}}; AX.activationPoint={207, 834}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 772}, {414, 36}}; opaque; alpha=1>
| | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cd670; AX=Y; AX.id='Touchable'; AX.label='Sign in'; AX.frame={{0, 816}, {414, 36}}; AX.activationPoint={207, 834}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 36}}; opaque; alpha=1>
| | | | | | | | | | | | | | | | |--<RCTTextView:0x7fb2a55b3040; AX=Y; AX.label='Sign in'; AX.frame={{0, 816}, {414, 36.5}}; AX.activationPoint={207, 834.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 0}, {414, 36.5}}; alpha=1>
| | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cd360; AX=N; AX.label='Welcome! Let's go!'; AX.frame={{0, 44}, {414, 772}}; AX.activationPoint={207, 430}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {414, 772}}; opaque; alpha=1>
| | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cd050; AX=N; AX.frame={{207, 500}, {0, 316}}; AX.activationPoint={207, 658}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{207, 456}, {0, 316}}; opaque; alpha=1>
| | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55ccd40; AX=N; AX.label='Let's go!'; AX.frame={{147, 460}, {120, 40}}; AX.activationPoint={207, 480}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{147, 416}, {120, 40}}; opaque; alpha=1>
| | | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cca30; AX=Y; AX.id='Touchable'; AX.label='Let's go!'; AX.frame={{147, 460}, {120, 40}}; AX.activationPoint={207, 480}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 0}, {120, 40}}; opaque; alpha=1>
| | | | | | | | | | | | | | | | | |--<RCTTextView:0x7fb2a55cc800; AX=Y; AX.label='Let's go!'; AX.frame={{164, 471}, {86, 18.5}}; AX.activationPoint={207, 480.25}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{17, 11}, {86, 18.5}}; alpha=1>
| | | | | | | | | | | | | | | |--<RCTTextView:0x7fb2a55cc210; AX=Y; AX.label='Answer two quick questions to get started.'; AX.frame={{68, 379.5}, {278, 50.5}}; AX.activationPoint={207, 404.75}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{68, 335.5}, {278, 50.5}}; alpha=1>
| | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cbd20; AX=N; AX.label='Welcome to '; AX.frame={{97.5, 44}, {219, 336}}; AX.activationPoint={207, 212}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{97.5, 0}, {219, 336}}; opaque; alpha=1>
| | | | | | | | | | | | | | | | |--<RCTView:0x7fb2a55cba10; AX=N; AX.label='Welcome to '; AX.frame={{97.5, 327}, {219, 33}}; AX.activationPoint={207, 343.5}; AX.traits='UIAccessibilityTraitNone'; AX.focused='N'; frame={{0, 283}, {219, 33}}; opaque; alpha=1>
| | | | | | | | | | | | | | | | | |--<RCTImageView:0x7fb2a55cb730; AX=N; AX.id='/Users/.../Library/Developer/CoreSimulator/Devices/4FF22CAE-8C08-4FA8-8CB7-DEC31EB77737/data/Containers/Data/Application/608DC539-4BB6-4C2D-934E-98C4863ED4D1/Library/Application Support/CodePush/76158f1b9b351e2881c905cc31e6f30ea33a2e52829f92e0b092dcc45be9cfde/CodePush/assets/app/assets/images/logo#2x.png'; AX.frame={{258.5, 333}, {58, 21}}; AX.activationPoint={287.5, 343.5}; AX.traits='UIAccessibilityTraitImage'; AX.focused='N'; frame={{161, 6}, {58, 21}}; alpha=1>
| | | | | | | | | | | | | | | | | |--<RCTTextView:0x7fb2a55cb500; AX=Y; AX.label='Welcome to '; AX.frame={{97.5, 327}, {162, 33.5}}; AX.activationPoint={178.5, 343.75}; AX.traits='UIAccessibilityTraitStaticText'; AX.focused='N'; frame={{0, 0}, {162, 33.5}}; alpha=1>
9 |
10 | it('WelcomeScreen: Loaded', async () => {
> 11 | await expect(element(by.id('WelcomeScreen_Contents'))).toBeVisible();
| ^
12 | });
I also tried some other values:
<View
style={styles.contents}
testID="WelcomeScreen_Contents1"
accessibilityHint="WelcomeScreen_Contents2"
accessibilityLabel="WelcomeScreen_Contents3"
>
And the following tests:
it('WelcomeScreen: Loaded 1', async () => {
await expect(element(by.id('WelcomeScreen_Contents1'))).toBeVisible();
});
it('WelcomeScreen: Loaded 2', async () => {
await expect(element(by.id('WelcomeScreen_Contents2'))).toBeVisible();
});
it('WelcomeScreen: Loaded 3', async () => {
await expect(element(by.id('WelcomeScreen_Contents3'))).toBeVisible();
});
Detox config at package.json
"detox": {
"configurations": {
"iphonexr": {
"binaryPath": "ios/build/xxx/Build/Products/Release-iphonesimulator/xxx.app",
"build": "RCT_NO_LAUNCH_PACKAGER=1 xcodebuild -quiet -workspace ios/xxx.xcworkspace -UseNewBuildSystem=NO -configuration Release -scheme xxx -derivedDataPath ios/build/xxx -sdk iphonesimulator",
"type": "ios.simulator",
"name": "iPhone Xʀ"
},
"iphonese": {
"binaryPath": "ios/build/xxx/Build/Products/Release-iphonesimulator/xxx.app",
"build": "RCT_NO_LAUNCH_PACKAGER=1 xcodebuild -quiet -workspace ios/xxx.xcworkspace -UseNewBuildSystem=NO -configuration Release -scheme xxx -derivedDataPath ios/build/xxx -sdk iphonesimulator",
"type": "ios.simulator",
"name": "iPhone SE"
}
},
"test-runner": "jest"
}
}

After hours of debugging I found out the problems were:
- CodePush overriding my changes
- RN's View Flattening ( https://twitter.com/shergin/status/1058393187079704576 )
I added a small check so I can disable CodePush for Test builds and it works properly now.

Related

extract data from sql query json format

I have a table sensor_measurements and the columns measurements and measure_at (timestamp)
select measured_at, pollutants
from sensor_measurements;
which gives:
October 22, 2019, 9:00 PM
[{"name": "NO", "units": "ppm", "concentration": 0.002161, "temporal_resolution": "1h"},
{"name": "NO2", "units": "ppm", "concentration": 0.002, "temporal_resolution": "1h"},
{"name": "TEMP", "units": "celsius", "concentration": 28, "temporal_resolution": "1h"},
{"name": "HUM", "units": "percent", "concentration": 38, "temporal_resolution": "1h"},
{"name": "PM10", "units": "µg/m3", "concentration": 8, "temporal_resolution": "1h"},
{"name": "PM25", "units": "µg/m3", "concentration": 7, "temporal_resolution": "1h"}]
October 22, 2019, 10:00 PM
[{"name": "NO", "units": "ppm", "concentration": 0.002205, "temporal_resolution": "1h"},
{"name": "NO2", "units": "ppm", "concentration": 0.008, "temporal_resolution": "1h"},
{"name": "TEMP", "units": "celsius", "concentration": 28, "temporal_resolution": "1h"},
{"name": "HUM", "units": "percent", "concentration": 38, "temporal_resolution": "1h"},
{"name": "PM10", "units": "µg/m3", "concentration": 9, "temporal_resolution": "1h"},
{"name": "PM25", "units": "µg/m3", "concentration": 8, "temporal_resolution": "1h"}]
October 22, 2019, 11:00 PM
[{"name": "NO", "units": "ppm", "concentration": 0.002209, "temporal_resolution": "1h"},
{"name": "NO2", "units": "ppm", "concentration": 0.004, "temporal_resolution": "1h"},
{"name": "TEMP", "units": "celsius", "concentration": 28, "temporal_resolution": "1h"},
{"name": "HUM", "units": "percent", "concentration": 38, "temporal_resolution": "1h"},
{"name": "PM10", "units": "µg/m3", "concentration": 8, "temporal_resolution": "1h"},
{"name": "PM25", "units": "µg/m3", "concentration": 7, "temporal_resolution": "1h"}]
October 23, 2019, 12:00 AM
[{"name": "NO", "units": "ppm", "concentration": 0.002125, "temporal_resolution": "1h"},
{"name": "NO2", "units": "ppm", "concentration": 0.004, "temporal_resolution": "1h"},
{"name": "TEMP", "units": "celsius", "concentration": 28, "temporal_resolution": "1h"},
{"name": "HUM", "units": "percent", "concentration": 39, "temporal_resolution": "1h"}]
October 23, 2019, 4:00 PM
[{"name": "NO", "units": "ppm", "concentration": 0.004563, "temporal_resolution": "1h"},
{"name": "TEMP", "units": "celsius", "concentration": 34, "temporal_resolution": "1h"},
{"name": "HUM", "units": "percent", "concentration": 28, "temporal_resolution": "1h"}]
I want to extract the timestamp, pollutant and it's value (concentration!
Ideally , I want to create three columns with timestamp, pollutant and value in order to download as csv.
The database type is PostgreSQl (in metabase.com)
I did it on postgres.
First of all you have to have type represents your data:
CREATE TYPE x as ("name" VARCHAR , "units" VARCHAR , "concentration" FLOAT, "temporal_resolution" VARCHAR );
Next, you can use json as joined table:
SELECT measured_at, name, concentration
FROM sensor_measurements
LEFT JOIN LATERAL json_populate_recordset(null::x, pollutants::json) ON true;

Having a issue with shopify resizing image from liquid file

Hello I'm trying to edit an image make it smaller or custom size but not familiar with liquid. Thank you for the help guys. I added some code. I think its default as certain percentage but not sure. Let me know if you guys need some extra code or information from me.
// settings_data.json file
"index-newsletter": {
"type": "index-newsletter",
"settings": {
"title": "Newsletter",
"richtext": "<p>Subscribe to get special offers, free giveaways, and once-in-a-lifetime deals.<\/p>",
"width": "full",
"flex_align": "align--middle-left",
"text_color": "dark",
"height": "screen-height-one-third",
"bg_image": "shopify:\/\/shop_images\/Grazioso_Logo321321_db2a67b3-d13f-4d64-a73d-c82f176fd6a5.png",
"overlay_opacity": 50,
"overlay_color": "#ffffff"
}
},
<!-- /sections/newsletter.liquid -->
{%- assign img_url = section.settings.bg_image | img_url: '1x1' | replace: '_1x1.', '_{width}x.' -%}
<style>
{%- if section.settings.text_color == 'white' -%}
.index-newsletter-{{ section.id }},
.index-newsletter-{{ section.id }} .input-group.newsletter-form input { color: #fff; }
{%- endif -%}
</style>
<div class="index-newsletter index-newsletter-{{ section.id }}" data-section-id="{{ section.id }}" data-section-type="newsletter">
<div class="wide-image js-overflow-container {{ section.settings.height }}"
data-aos-duration="500"
data-aos="fade-up">
<div class="hero__content__wrapper hero__content--transparent {{ section.settings.flex_align }}">
<div class="hero__content hero__content--{{ section.settings.width }} js-overflow-content">
<div class="newsletter__content">
{% if section.settings.title != '' %}
<h5 class="newsletter__title">{{ section.settings.title }}</h5>
{% endif %}
{% if collection.description != '' %}
<div class="rte">
{{ section.settings.richtext }}
</div>
{% endif %}
<div class="newsletter-signup">
{% include 'newsletter-form' %}
</div>
</div>
</div>
</div>
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/>
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}
<noscript>
<img src="{{ section.settings.bg_image | img_url: '1440x' }}" alt="{{ section.settings.bg_image.alt | default: collection.title }}" class="responsive-wide-image"/>
</noscript>
{% assign overlay_opacity = section.settings.overlay_opacity | times: 0.01 %}
<div class="image-overlay" style="background-color:{{ section.settings.overlay_color }} !important; opacity:{{ overlay_opacity }};"></div>
{% endif %}
</div>
</div>
{% schema %}
{
"name": "Newsletter",
"settings": [
{
"type": "header",
"content": "Content"
},
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Newsletter"
},
{
"id": "richtext",
"type": "richtext",
"label": "Subheading",
"default": "<p>Subscribe to get special offers, free giveaways, and once-in-a-lifetime deals.</p>"
},
{
"type": "paragraph",
"content": "Subscribers are under 'Accepts Marketing' in your [customer admin](/admin/customers)."
},
{
"type": "select",
"id": "width",
"label": "Width",
"default": "full",
"options": [
{ "value": "full", "label": "Full" },
{ "value": "default", "label": "Default" }
]
},
{
"type": "select",
"id": "flex_align",
"label": "Text alignment",
"default": "align--middle-left",
"options": [
{ "value": "align--middle-left", "label": "Left" },
{ "value": "align--middle-center", "label": "Center" },
{ "value": "align--middle-right", "label": "Right" }
]
},
{
"type": "select",
"id": "text_color",
"label": "Text color",
"default": "dark",
"options": [
{ "value": "dark", "label": "Dark" },
{ "value": "white", "label": "White" }
]
},
{
"type": "select",
"id": "height",
"label": "Section height",
"default": "screen-height-one-third",
"options": [
{ "value": "screen-height-one-half", "label": "1/2 of screen"},
{ "value": "screen-height-one-third", "label": "1/3 of screen"},
{ "value": "five-fifty-height-hero ", "label": "550px" },
{ "value": "four-fifty-height-hero", "label": "450px" },
{ "value": "three-fifty-height-hero", "label": "350px" },
{ "value": "two-fifty-height-hero", "label": "250px" },
{ "value": "image-height", "label": "Image height" }
]
},
{
"type": "header",
"content": "Background"
},
{
"type": "image_picker",
"id": "bg_image",
"label": "Background image"
},
{
"type": "range",
"id": "overlay_opacity",
"label": "Opacity",
"info": "Increase contrast for legible text.",
"unit": "%",
"min": 0,
"max": 90,
"step": 5,
"default": 0
},
{
"type": "color",
"id": "overlay_color",
"label": "Overlay color",
"default": "#fff"
}
],
"presets": [
{
"category": "Promotional",
"name": "Newsletter"
}
]
}
{% endschema %}
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/>
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}
{
"type": "select",
"id": "height",
"label": "Section height",
"default": "screen-height-one-third",
"options": [
{ "value": "screen-height-one-half", "label": "1/2 of screen"},
{ "value": "screen-height-one-third", "label": "1/3 of screen"},
{ "value": "five-fifty-height-hero ", "label": "550px" },
{ "value": "four-fifty-height-hero", "label": "450px" },
{ "value": "three-fifty-height-hero", "label": "350px" },
{ "value": "two-fifty-height-hero", "label": "250px" },
{ "value": "image-height", "label": "Image height" }
]
},
in the theme editing, if you choose the height setting to image height. These will happen
because you are using lazyload, there will be a small picture of 18px used, hence this line src="{{ section.settings.bg_image | img_url: '18x' }}"
the picture will automatically resize base on the screen width;
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
if you want to have the image at max-width 2048, just remove the the number from data-width; I.e. I only want image size 180 - 2048. I will remove 2450, 2700, 3000, ...
another solution is to add max-width to the image;i.e add style="max-width: 500px" to the img tag
{% if section.settings.bg_image %}
{% if section.settings.height == 'image-height' %}
<img class="lazyload responsive-wide-image"
alt="{{ section.settings.bg_image.alt | default: section.settings.title }}"
src="{{ section.settings.bg_image | img_url: '18x' }}"
data-src="{{ img_url }}"
data-widths="[180, 360, 540, 720, 900, 1080, 1296, 1512, 1728, 2048, 2450, 2700, 3000, 3350, 3750, 4100]"
data-aspectratio="{{ section.settings.bg_image.aspect_ratio }}"
data-parent-fit="cover"
data-sizes="auto"/
style="max-width: 500px;">
{% else %}
<div class="background-size-cover lazyload" data-bgset="{% include 'bgset', image: section.settings.bg_image %}"></div>
{% endif %}

vega grouping difference for vertical and horizontal bar chart?

thanks in advance! I am trying to make a grouped bar chart with Vega. So I took the "stacked bar chart example" data (removed the stacking transform), and made a vertical one and horizontal one. The strange thing is, the horizontal one worked as I expected, but the vertical one has duplicated overlapping bars on each individual groups. I made them exactly the same way, only switching the properties. I will post my json file below.
Vertical bar chart:
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic stacked bar chart example.",
"width": 500,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"x": 0, "y": 28, "c": 0}, {"x": 0, "y": 55, "c": 1},
{"x": 1, "y": 43, "c": 0}, {"x": 1, "y": 91, "c": 1},
{"x": 2, "y": 81, "c": 0}, {"x": 2, "y": 53, "c": 1},
{"x": 3, "y": 19, "c": 0}, {"x": 3, "y": 87, "c": 1},
{"x": 4, "y": 52, "c": 0}, {"x": 4, "y": 48, "c": 1},
{"x": 5, "y": 24, "c": 0}, {"x": 5, "y": 49, "c": 1},
{"x": 6, "y": 87, "c": 0}, {"x": 6, "y": 66, "c": 1},
{"x": 7, "y": 17, "c": 0}, {"x": 7, "y": 27, "c": 1},
{"x": 8, "y": 68, "c": 0}, {"x": 8, "y": 16, "c": 1},
{"x": 9, "y": 49, "c": 0}, {"x": 9, "y": 15, "c": 1}
]
}
],
"scales": [
{
"name": "xscale",
"type": "band",
"range": "width",
"domain": {"data": "table", "field": "c"}
},
{
"name": "yscale",
"type": "linear",
"range": "height",
"domain": {"data": "table", "field": "y"}
},
{
"name": "color",
"type": "ordinal",
"range": "category",
"domain": {"data": "table", "field": "c"}
}
],
"axes": [
{"orient": "bottom", "scale": "xscale", "zindex": 1},
{"orient": "left", "scale": "yscale", "zindex": 1}
],
"marks": [
{
"type": "group",
"from": {
"facet": {
"name": "facet",
"data": "table",
"groupby": "c"
}
},
"encode": {
"enter": {
"x": {"scale": "xscale", "field": "c"}
}
},
"signals": [
{"name": "width", "update": "bandwidth('xscale')"}
],
"scales": [
{
"name": "inner",
"type": "band",
"range": "width",
"domain": {"data": "facet", "field": "x"}
}
],
"axes": [
{"orient": "top", "scale": "inner", "tickSize": 0, "labelPadding": 10, "zindex": 2, "title": "x"}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "inner", "field": "x"},
"width": {"scale": "inner", "band": 1, "offset": -1},
"y": {"scale": "yscale", "field": "y"},
"y2": {"scale": "yscale", "value": 0},
"fill": {"scale": "color", "field": "c"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fillOpacity": {"value": 0.5}
}
}
}
]
}]
}
Horizontal bar chart:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic stacked bar chart example.",
"width": 500,
"height": 200,
"padding": 5,
"data": [
{
"name": "table",
"values": [
{"x": 0, "y": 28, "c": 0}, {"x": 0, "y": 55, "c": 1},
{"x": 1, "y": 43, "c": 0}, {"x": 1, "y": 91, "c": 1},
{"x": 2, "y": 81, "c": 0}, {"x": 2, "y": 53, "c": 1},
{"x": 3, "y": 19, "c": 0}, {"x": 3, "y": 87, "c": 1},
{"x": 4, "y": 52, "c": 0}, {"x": 4, "y": 48, "c": 1},
{"x": 5, "y": 24, "c": 0}, {"x": 5, "y": 49, "c": 1},
{"x": 6, "y": 87, "c": 0}, {"x": 6, "y": 66, "c": 1},
{"x": 7, "y": 17, "c": 0}, {"x": 7, "y": 27, "c": 1},
{"x": 8, "y": 68, "c": 0}, {"x": 8, "y": 16, "c": 1},
{"x": 9, "y": 49, "c": 0}, {"x": 9, "y": 15, "c": 1}
]
}
],
"scales": [
{
"name": "y",
"type": "band",
"range": "height",
"domain": {"data": "table", "field": "c"}
},
{
"name": "x",
"type": "linear",
"range": "width",
"domain": {"data": "table", "field": "y"}
},
{
"name": "color",
"type": "ordinal",
"range": "category",
"domain": {"data": "table", "field": "c"}
}
],
"axes": [
{"orient": "bottom", "scale": "x", "zindex": 1},
{"orient": "left", "scale": "y", "zindex": 1}
],
"marks": [
{"type": "group",
"from": {
"facet": {
"name": "facet",
"data": "table",
"groupby": "c"
}
},
"encode": {
"enter": {
"y": {"scale": "y", "field": "c"}
}
},
"signals": [
{"name": "height", "update": "bandwidth('y')"}
],
"scales": [
{
"name": "pos",
"type": "band",
"range": "height",
"domain": {"data": "facet", "field": "x"}
}
],
"axes": [
{"orient": "right", "scale": "pos", "tickSize": 0, "labelPadding": 10, "zindex": 3}
],
"marks": [{
"type": "rect",
"from": {"data": "facet"},
"encode": {
"enter": {
"y": {"scale": "pos", "field": "x"},
"height": {"scale": "pos", "band": 1, "offset":-1},
"x": {"scale": "x", "field": "y"},
"x2": {"scale": "x", "value": 0},
"fill": {"scale": "color", "field": "c"}
}
}
}]
}]
}
Images:
Is this something I didn't setup correctly in the specs? Thanks.
I figured it out. The inner chart marks needs to be sourced from facet instead of the original table
"from": {"data": "facet"}
That fixed it.

How do I implement Schema.org markups on Shopify?

I've recently started to work for a beauty company who wants to implement rich snippets for their products page. I know how Schema.org markups work as I've copied a general Organization one that my friend used for a mobile app development company.
Here's the code's template I'm referring to:
<script type="application/ld+json">
{ "#context": "http://schema.org",
"#type": "Organization",
"name": "Company name",
"legalName" : "Legal Name",
"url": "Company URL",
"logo": "internal logo link",
"foundingDate": "founding date",
"founders": [
{
"#type": "Person",
"name": "Founder"
} ],
"address": {
"#type": "PostalAddress",
"streetAddress": "Street Address",
"addressLocality": "City",
"addressRegion": "Region",
"postalCode": "Postcode",
"addressCountry": "United Kingdom"
},
"contactPoint": {
"#type": "ContactPoint",
"contactType": "customer support",
"telephone": "Phone Number",
"email": "email contact"
},
"sameAs": [
"Social Media Links"
]}
</script>
Unluckily for me, this company's site is Shopify-based.
During my endless researches, I came across many different sites and blogs which were telling me to simply add this script into the theme.liquid file but I can't find a way to implement it properly. This is the blog post I was browsing.
Has anyone of you got any experience with this, or should I contact a Shopify Developer and let him do the job?
I've already tried to use this code template (which I simply copied and pasted in the liquid file):
<script type="application/ld+json">
{
"#context": "http://schema.org/",
"#type": "Product",
"name": "{{ product.title }}",
"sku": "{{ product.variants.first.sku }}",
"gtin14": "{{ product.variants.first.barcode }}",
"brand": "{{ product.vendor }}",
"description": "{{ product.description | strip_html | escape }}",
"image": "https:{{ product.featured_image.src | img_url: 'grande' }}",
"offers": {
"#type": "Offer",
"priceCurrency": "{{ shop.currency }}",
"price": "{{ product.price |money_without_currency | strip_html }}",
"itemCondition" : "http://schema.org/NewCondition",
"availability" : "{% if product.available == true %}http://schema.org/InStock{% else %}http://schema.org/OutOfStock{% endif %}",
"url" : "{{ shop.url }}{{ product.url }}"
}
}
</script>
I don't understand what's not working for you?
Like the article says, place it into the theme.liquid file.
But instead of just placing the product schema, which, when not on a product template, will cause a ton of errors because {{ product.title }} won't render anything; use template if statements to get results for index, product and article.
Here's a full, working example:
<script type="application/ld+json">
{%- if template == 'index' -%}
{
"#context": "http://schema.org",
"#type": "WebSite",
"name": "{{ shop.name }}",
"alternateName": "{{ shop.description }}",
"url": "{{ shop.url }}"
}
{%- elsif template == 'product' %}
{
"#context": "http://schema.org",
"#type": "Product",
"description": "{{ product.description | strip_html }}",
"name": "{{ product.title }}",
"image": "{{ product.featured_image | img_url: 'master' }}",
"manufacturer": "{{ product.vendor }}",
"category": "{{ collection.title }}",
"sku": "{{ product.selected_or_first_available_variant.sku }}",
"url": "{{ shop.url | append: product.url }}",
"offers": {
"#type": "Offer",
"availability": "InStock",
"price": "{{ product.price | money_without_currency }}",
"priceCurrency": "{{ shop.currency }}"
}
}
{%- elsif template == 'article' %}
{
"#context": "http://schema.org",
"#type": "NewsArticle",
"image": {
"#type": "imageObject",
"url": "https:{{ article.image.src | img_url: 'original' }}",
"width": "1024px",
"height": "1024px"
},
"keywords": "{%- for tag in article.tags -%}{{ tag }}{%- unless forloop.last -%}, {%- endunless -%}{%- endfor -%}",
"url": "{{ shop.url | append: article.url }}",
"description": "{{ article.content | truncatewords: 100 | strip_html }}",
"mainEntityOfPage": {
"#type": "WebPage",
"#id": "https://google.com/article"
},
"headline": "{{ article.title }}",
"datePublished": "{{ article.published_at }}",
"dateModified": "{{ article.published_at }}",
"author": {
"#type": "Person",
"name": "{{ article.author }}"
},
"publisher": {
"#type": "Organization",
"name": "{{ shop.name }}",
"logo": {
"#type": "ImageObject",
"url": "{{ shop.url }}"
}
},
"commentCount": "{{ article.comments_count }}"
}
{%- endif %}
</script>

subarray models mapping issues with gridpanel extjs 4

stackoverflow team member I am having problem with displaying the json subarray data to my gridpanel my json data is below
{
"total": 11,
"success": true,
"employeetaskdetdata": [{
"subject": "Work in progress",
"employee": {
"username": "yogen",
"designation": {
"department": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"departname": "Programmer",
"createdby": 1,
"createdon": 1335764655000,
"modifiedby": 1,
"modifiedon": 1335764655000,
"departdescr": "<b>?Programmer</b>",
"id": 2
},
"createdby": 1,
"createdon": 1335764825000,
"modifiedby": 1,
"modifiedon": 1335764825000,
"designame": "Senior JAVA Programmer",
"desigdescr": "<b>?Senior JAVA Programmer</b>",
"id": 6
},
"createdby": 1,
"createdon": 1335765074000,
"modifiedby": 1,
"modifiedon": 1335765074000,
"dateofbirth": 1335810600000,
"joindate": 1337106600000,
"firstname": "Yogendra",
"surname": "Singh",
"gender": "M",
"marital": "U",
"nationality": "",
"contactno": "",
"mobileno": "",
"email": "",
"otheremail": "",
"fathername": "",
"mothername": "",
"accountno": "",
"salary": "",
"bank": {
"bankname": "ICICI Bank",
"bankaddress": "ICICI Bank Nanpura",
"id": 1
},
"address": "",
"id": 6,
"password": "123"
},
"todaysdate": "2012-05-05",
"createdby": 6,
"createdon": 1336203851000,
"modifiedby": 6,
"modifiedon": 1336203851000,
"project": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"createdby": 1,
"createdon": 1335765435000,
"modifiedby": 1,
"modifiedon": 1335765435000,
"projectname": "Project I",
"projecttitle": "Project I",
"projectdesc": "<b>Kintu Design Pvt ltd new Project I</b>",
"projectstart": 1335810600000,
"projectend": 1336761000000,
"id": 1
},
"task": {
"duration": 4.0,
"employee": [{
"username": "hiren",
"designation": {
"department": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"departname": "Programmer",
"createdby": 1,
"createdon": 1335764655000,
"modifiedby": 1,
"modifiedon": 1335764655000,
"departdescr": "<b>?Programmer</b>",
"id": 2
},
"createdby": 1,
"createdon": 1335764755000,
"modifiedby": 1,
"modifiedon": 1335764755000,
"designame": "Senior PHP Programmer",
"desigdescr": "<b>?Senior PHP Programmer</b>",
"id": 3
},
"createdby": 1,
"createdon": 1335765018000,
"modifiedby": 1,
"modifiedon": 1335765018000,
"dateofbirth": null,
"joindate": null,
"firstname": "Hiren",
"surname": "Patel",
"gender": "M",
"marital": "U",
"nationality": "",
"contactno": "",
"mobileno": "",
"email": "",
"otheremail": "",
"fathername": "",
"mothername": "",
"accountno": "",
"salary": "",
"bank": {
"bankname": "ICICI Bank",
"bankaddress": "ICICI Bank Nanpura",
"id": 1
},
"address": "",
"id": 4,
"password": "123"
}, {
"username": "yogen",
"designation": {
"department": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"departname": "Programmer",
"createdby": 1,
"createdon": 1335764655000,
"modifiedby": 1,
"modifiedon": 1335764655000,
"departdescr": "<b>?Programmer</b>",
"id": 2
},
"createdby": 1,
"createdon": 1335764825000,
"modifiedby": 1,
"modifiedon": 1335764825000,
"designame": "Senior JAVA Programmer",
"desigdescr": "<b>?Senior JAVA Programmer</b>",
"id": 6
},
"createdby": 1,
"createdon": 1335765074000,
"modifiedby": 1,
"modifiedon": 1335765074000,
"dateofbirth": 1335810600000,
"joindate": 1337106600000,
"firstname": "Yogendra",
"surname": "Singh",
"gender": "M",
"marital": "U",
"nationality": "",
"contactno": "",
"mobileno": "",
"email": "",
"otheremail": "",
"fathername": "",
"mothername": "",
"accountno": "",
"salary": "",
"bank": {
"bankname": "ICICI Bank",
"bankaddress": "ICICI Bank Nanpura",
"id": 1
},
"address": "",
"id": 6,
"password": "123"
}],
"createdby": 1,
"createdon": 1336460152000,
"modifiedby": 1,
"modifiedon": 1336460152000,
"project": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"createdby": 1,
"createdon": 1335765435000,
"modifiedby": 1,
"modifiedon": 1335765435000,
"projectname": "Project I",
"projecttitle": "Project I",
"projectdesc": "<b>Kintu Design Pvt ltd new Project I</b>",
"projectstart": 1335810600000,
"projectend": 1336761000000,
"id": 1
},
"percentdone": 55,
"durationunit": "d",
"startdate": 1336415400000,
"parentid": 2,
"taskindex": 0,
"taskname": "Sub Task 2 1",
"enddate": 1336761000000,
"priority": 2,
"id": 3,
"depth": 2
},
"percentdone": 20,
"totalworkedhrs": -9.5,
"starttime": "09:00:00",
"finishtime": "00:00:00",
"id": 1,
"description": "<b>Work in progress</b>",
"hours": 0,
"minutes": 30
}, {
"subject": "Work in progresss",
"employee": {
"username": "yogen",
"designation": {
"department": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"departname": "Programmer",
"createdby": 1,
"createdon": 1335764655000,
"modifiedby": 1,
"modifiedon": 1335764655000,
"departdescr": "<b>?Programmer</b>",
"id": 2
},
"createdby": 1,
"createdon": 1335764825000,
"modifiedby": 1,
"modifiedon": 1335764825000,
"designame": "Senior JAVA Programmer",
"desigdescr": "<b>?Senior JAVA Programmer</b>",
"id": 6
},
"createdby": 1,
"createdon": 1335765074000,
"modifiedby": 1,
"modifiedon": 1335765074000,
"dateofbirth": 1335810600000,
"joindate": 1337106600000,
"firstname": "Yogendra",
"surname": "Singh",
"gender": "M",
"marital": "U",
"nationality": "",
"contactno": "",
"mobileno": "",
"email": "",
"otheremail": "",
"fathername": "",
"mothername": "",
"accountno": "",
"salary": "",
"bank": {
"bankname": "ICICI Bank",
"bankaddress": "ICICI Bank Nanpura",
"id": 1
},
"address": "",
"id": 6,
"password": "123"
},
"todaysdate": "2012-05-05",
"createdby": 6,
"createdon": 1336204557000,
"modifiedby": 6,
"modifiedon": 1336204557000,
"project": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"createdby": 1,
"createdon": 1335765435000,
"modifiedby": 1,
"modifiedon": 1335765435000,
"projectname": "Project I",
"projecttitle": "Project I",
"projectdesc": "<b>Kintu Design Pvt ltd new Project I</b>",
"projectstart": 1335810600000,
"projectend": 1336761000000,
"id": 1
},
"task": {
"duration": 4.0,
"employee": [{
"username": "hiren",
"designation": {
"department": {
"company": {
"cmpname": "Kintu Designs Pvt ltd",
"cmptitle": "Kintu Designs Pvt ltd",
"cmpdesc": "<b>D-104 Toral Appartment Surat,<br>Timalyabad.</b>",
"cmpfax": "8128812153",
"cmpcontact": "8128812153",
"cmpwebsite": "www.kintudesigns.com",
"cmpemail1": "yaryan997#gmail.com",
"cmpemail2": "yaryan997#gmail.com",
"cmpcountry": "India",
"cmpstate": "Gujarat",
"cmpcity": "Surat",
"cmpaddress": "D-104 Toral Appartment Surat,\nTimalyabad.",
"cmplogo": "calendar.png",
"cmplogopath": "upload/images/",
"cmpcreatedby": 1,
"cmpcreatedon": 1335764510000,
"cmpmodifiedon": 1335764510000,
"cmpmodifiedby": 0,
"id": 1
},
"departname": "Programmer",
"createdby": 1,
"createdon": 1335764655000,
"modifiedby": 1,
"modifiedon": 1335764655000,
"departdescr": "<b>?Programmer</b>",
"id": 2
},
"createdby": 1,
"createdon": 1335764755000,
"modifiedby": 1,
"modifiedon": 1335764755000,
"designame": "Senior PHP Programmer",
"desigdescr": "<b>?Senior PHP Programmer</b>",
"id": 3
},
"createdby": 1,
"createdon": 1335765018000,
"modifiedby": 1,
"modifiedon": 1335765018000,
"dateofbirth": null,
"joindate": null,
"firstname": "Hiren",
"surname": "Patel",
"gender": "M",
"marital": "U",
"nationality": "",
"contactno": "",
"mobileno": "",
"email": "",
"otheremail": "",
"fathername": "",
"mothername": "",
"accountno": "",
"salary": "",
"bank": {
"bankname": "ICICI Bank",
"bankaddress": "ICICI Bank Nanpura",
"id": 1
},
"address": "",
"id": 4,
"password": "123"
}]
}
and my model is below
Ext.define('DEV.model.employeetaskdetModel', {
extend: 'Ext.data.Model',
fields : [
{ name: 'id'},
{ name: 'taskname', mapping:'task.taskname'},
{ name: 'firstname', mapping: 'employee.firstname'},
{ name: 'employee',type: 'auto'},
{ name: 'percentdone'}
]
});
and my grid panel columns are below
columns: [ {
xtype: 'gridcolumn',
dataIndex: 'percentdone',
text: 'Percent Done'
}, {
xtype: 'gridcolumn',
dataIndex: 'firstname',
text: 'First Name'
}]
I am not able to show the firstname in my gridPanel. But when I change the firstname column with below code it shows me the firstname gridpanel correctly.
{
xtype: 'gridcolumn',
dataIndex: 'employee',
text: 'User Name',
renderer: function (employee) {
var result = [];
employee = employee || [];
var value = employee.firstname;
if (value) {
result.push(value);
}
return result;
console.log(employee.firstname);
}
},
please suggest me why my gridpanel didn't show the firstname of user directly. What's the problem with my code. And why its showing the data when I add the renderer function.
I encountered a similar problem and solve it.
Mapping property is not required for mapping nested json data.
Model:
Ext.define("Model", {
extend: "Ext.data.Model",
fields: [
{name: "id", type: "int"},
{name: "name.name"},
{name: "phone", mapping: "name.phone"},
{name: "descr", type: "string", mapping:'description'}
]
});
Store with data that we will recieve from jsfiddle test echo ajax service:
var Store = Ext.create("Ext.data.Store", {
model: "Model",
autoLoad: true,
proxy: {
type: 'ajax',
url: '/echo/json/',
//
actionMethods: {read: 'POST'}, // echo ajax service required
extraParams: {
json: Ext.JSON.encode({
root: [
{id: 1, name: {name:"John", phone: "123"}, description:"Fapfapfap"},
{id: 2, name: {name:"Danny", phone: "234"}, description:"Boobooboo"},
{id: 3, name: {name:"Tom", phone: "345"}, description:"Tralala"},
{id: 4, name: {name:"Jane", phone: "456"}, description:"Ololo"},
]
})
},
reader: {
type: 'json',
root: 'root'
}
},
});
Grid:
Ext.create("Ext.grid.Panel", {
store: Store,
columns: [
{dataIndex: "id", header:"ID"},
{dataIndex: "name.name", header:"Name", flex: 1, editor: "textfield"},
{dataIndex: "phone", header:"Phone", flex: 1, editor: "textfield"},
{dataIndex: "descr", header: "Description", flex: 2, editor: "htmleditor"}
],
renderTo: Ext.getBody(),
});
This should work, if other problems is absent.
Here you can see work example http://jsfiddle.net/Fgh7z/1/