Hey guys,
I am currently working on an optionDatasource for a listgrid field. The listgrid field is of type “SelectItem” and should also show valueIcons. The datasource works fine, but I have some Issues getting valueIcons to work.
To do so I’ve overridden the getValueIcon method for the listgrid field. In this function the given value gets wrapped by imageURLPrefix and imageURLSuffix and is getting returned. If the value is undefined or null it will return null for not printing an icon.
This works for all elements inside the list but not for the selected object, which will have the imageURLSuffix twice (e.g. “US.png.png”) and thus it won’t show an icon (only US.png exists).
Did I implement getValueIcon the wrong way or is this an issue of yours?
Another issue appears when setting data to the list grid. When setting the value of entries (e. g. US) the listgrid will only show these values instead of the displayValue (e. g. USA) and also won’t show any icon. When setting the displayValue (which feels wrong) the correct name will be shown and also no icon. When starting to edit a record the select item appears and correctly shows the displayValue for the given value and without the first issue mentioned above the icon would show. For the set displayValue this won’t work anymore. The displayValue will stay as selected object, but the dataSource won’t find an entry with the displayValue as value and thus the select item will try to get the icon for the set displayValue (e. g. USA.png instead of US.png).
How do I make the listGrid resolve values with the dataSource for getting the displayValue?
Or am I going down the wrong road?
You can see the values shown by the listgrid (US, DE & CU) instead of its displayValues (USA, Deutschland & Kuba) and without its icons. when clicking on a cell, the record will start editing and the select item will resolve the data for given value. You can’t see values for the selected objects because of the first issue mentioned. When opening the list everything is fine, but after end editing the displayValue is lost again.
Code for reproducing the issues:
Best Regards
I am currently working on an optionDatasource for a listgrid field. The listgrid field is of type “SelectItem” and should also show valueIcons. The datasource works fine, but I have some Issues getting valueIcons to work.
To do so I’ve overridden the getValueIcon method for the listgrid field. In this function the given value gets wrapped by imageURLPrefix and imageURLSuffix and is getting returned. If the value is undefined or null it will return null for not printing an icon.
Code:
getValueIcon : function (value) { if (typeof(value) == "undefined" || value == null) { return null; } return this.imageURLPrefix + value + this.imageURLSuffix; }
Did I implement getValueIcon the wrong way or is this an issue of yours?
Another issue appears when setting data to the list grid. When setting the value of entries (e. g. US) the listgrid will only show these values instead of the displayValue (e. g. USA) and also won’t show any icon. When setting the displayValue (which feels wrong) the correct name will be shown and also no icon. When starting to edit a record the select item appears and correctly shows the displayValue for the given value and without the first issue mentioned above the icon would show. For the set displayValue this won’t work anymore. The displayValue will stay as selected object, but the dataSource won’t find an entry with the displayValue as value and thus the select item will try to get the icon for the set displayValue (e. g. USA.png instead of US.png).
How do I make the listGrid resolve values with the dataSource for getting the displayValue?
Or am I going down the wrong road?
You can see the values shown by the listgrid (US, DE & CU) instead of its displayValues (USA, Deutschland & Kuba) and without its icons. when clicking on a cell, the record will start editing and the select item will resolve the data for given value. You can’t see values for the selected objects because of the first issue mentioned. When opening the list everything is fine, but after end editing the displayValue is lost again.
Code for reproducing the issues:
Code:
countryData = [{ "Code" : "DE", "countryName" : "Deutschland" }, { "Code" : "IR", "countryName" : "Iran, Islamische Republik" }, { "Code" : "IS", "countryName" : "Island" }, { "Code" : "IL", "countryName" : "Israel" }, { "Code" : "IT", "countryName" : "Italien" }, { "Code" : "IT", "countryName" : "Italien - Mailand" }, { "Code" : "IT", "countryName" : "Italien - Rom" }, { "Code" : "JP", "countryName" : "Japan" }, { "Code" : "JP", "countryName" : "Japan - Tokio" }, { "Code" : "CM", "countryName" : "Kamerun" }, { "Code" : "KZ", "countryName" : "Kasachstan" }, { "Code" : "CO", "countryName" : "Kolumbien" }, { "Code" : "KP", "countryName" : "Korea, Demokr. Volksrep." }, { "Code" : "HR", "countryName" : "Kroatien" }, { "Code" : "CU", "countryName" : "Kuba" }, { "Code" : "LS", "countryName" : "Lesotho" }, { "Code" : "LV", "countryName" : "Lettland" }, { "Code" : "LT", "countryName" : "Litauen" }, { "Code" : "MW", "countryName" : "Malawi" }, { "Code" : "ML", "countryName" : "Malediven" }, { "Code" : "MA", "countryName" : "Marokko" }, { "Code" : "US", "countryName" : "USA" } ]; isc.ListGrid.create({ ID : "countryList", width : 500, height : 224, alternateRecordStyles : true, showAllRecords : true, canEdit : true, editEvent : "click", fields : [{ name : "countryField", title : "Country", canEdit : true, editorType : "SelectItem", imageURLPrefix : "https:\/\/www.cyon.ch\/img\/icons\/flags\/flags-iso\/shiny\/16\/", imageURLSuffix : ".png", editorProperties : { ID : "dayCountryGridField_43Editor", displayField : "countryName", valueField : "Code", getValueIcon : function (value) { if (typeof(value) == "undefined" || value == null) { return null } return this.imageURLPrefix + value + this.imageURLSuffix }, optionDataSource : isc.DataSource.create({ dataFormat : "json", ID : "countryDS", clientOnly : true, testData : countryData }), textMatchStyle : "substring", loadingDisplayValue : null, } } ], data : [{ countryField : "US" }, { countryField : "DE" } ], autoFetchData : true })
Comment