{"id":4778,"date":"2024-03-21T10:15:43","date_gmt":"2024-03-21T01:15:43","guid":{"rendered":"https:\/\/dandelions.co.jp\/blog\/?p=4778"},"modified":"2024-03-21T10:15:43","modified_gmt":"2024-03-21T01:15:43","slug":"leveraging-javascript-in-outsystems","status":"publish","type":"post","link":"http:\/\/dandelions.co.jp\/blog\/blog\/2024\/03\/21\/leveraging-javascript-in-outsystems\/","title":{"rendered":"Leveraging JavaScript in Outsystems"},"content":{"rendered":"\n<p>As an engineer blog, I would like to introduce the learning content that I am working on on a daily basis.<br>This is the second unit with the theme of low-code development.<\/p>\n\n\n\n<p>This time&#8217;s theme: &#8220;Using JavaScript in Outsystems&#8221;<\/p>\n\n\n\n<p>In our second unit, we regularly use Outsystems for low-code development.<br>Outsystems provides tools that allow you to develop intuitively by dragging and dropping parts without having to code as much as possible.<\/p>\n\n\n\n<p>However, if you want to implement details such as the UI part as you want, there may be cases where the properties provided by Outsystems are not enough.<br>In such a case, you may be able to implement your ideal by using JavaScript. This time I will introduce one such example.<\/p>\n\n\n\n<h2>\u4eca\u56de\u3084\u308a\u305f\u3044\u3053\u3068<\/h2>\n\n\n\n<p>This time, I would like to change the UI of DataGrid in Outsystems using JavaScript.<br>Specifically, we will introduce the following contents.<br>\u30fbCancel the DataGrid&#8217;s default setting of coloring every other row.<br>\u30fbColor a specific column of DataGrid with your favorite color<\/p>\n\n\n\n<p>How to use DataGrid<br>How to use the OutSystems Data Grid<\/p>\n\n\n\n<h2>DataGrid\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u8272\u4ed8\u3051\u8a2d\u5b9a\u3092\u89e3\u9664\u3059\u308b<\/h2>\n\n\n\n<p>First, we will change the coloring of every other row of the grid, which is set by DataGrid by default. <\/p>\n\n\n\n<p>Normally, if no settings are made, every other row of the grid will be colored automatically, as shown below. <br>We will change this using JavaScript. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1024\" height=\"495\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-15.png\" alt=\"\" class=\"wp-image-4779\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-15.png 1024w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-15-300x145.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-15-768x371.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>It&#8217;s hard to see because the color is so light, but you can see that the 2nd and 4th lines are colored gray.<\/figcaption><\/figure>\n\n\n\n<p>First, prepare a ClientAction (DataGridOnInitialize) for displaying the DataGrid in the screen element where the grid is located, and add an Input parameter called GridWidgetId.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-1.png\" alt=\"\" class=\"wp-image-4752\" width=\"356\" height=\"213\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-1.png 817w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-1-768x462.png 768w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/figure>\n\n\n\n<p>Next, in the Event item of the DataGrid property to which you want to apply JavaScript, set the ClientAction you created earlier to Handler.<br>At this time, also set the GridWidgetId added with the Input parameter.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-2.png\" alt=\"\" class=\"wp-image-4753\" width=\"360\" height=\"234\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-2.png 820w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-2-300x195.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-2-768x499.png 768w\" sizes=\"(max-width: 360px) 100vw, 360px\" \/><\/figure>\n\n\n\n<p>Set the following JavaScript in the ClientAction you created last.<br>(When defining a variable in JavaScript, the Input parameter GridWidgetId is specified.)<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-3.png\" alt=\"\" class=\"wp-image-4755\" width=\"368\" height=\"209\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-3.png 811w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-3-300x171.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-3-768x437.png 768w\" sizes=\"(max-width: 368px) 100vw, 368px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-12-1024x202.png\" alt=\"\" class=\"wp-image-4770\" width=\"532\" height=\"104\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-12-1024x202.png 1024w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-12-300x59.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-12-768x152.png 768w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-12.png 1089w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\/\/Get the Grid information created on the screen var grid = GridAPI.GridManager.GetGridById($parameters.GridWidgetId).provider; \/\/Abolish coloring for each row grid.alternatingRowStep = 0;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"1004\" height=\"481\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-6.png\" alt=\"\" class=\"wp-image-4761\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-6.png 1004w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-6-300x144.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-6-768x368.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>I was able to cancel the setting where every other line was colored gray.<\/figcaption><\/figure>\n\n\n\n<h2>Color only specified columns of DataGrid<\/h2>\n\n\n\n<p>Next, we will use JavaScript to color only specific columns of the grid.<br>I would like to color only the Name and Age columns in the grid above in gray to make it easier to visually understand that they are non-editable columns.<\/p>\n\n\n\n<p>This time, we will implement it by first coloring the entire grid gray, and then making only the editable Email column white.<\/p>\n\n\n\n<p>First, write the following CSS in the Style Sheet of the screen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-7.png\" alt=\"\" class=\"wp-image-4764\" width=\"371\" height=\"156\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-7.png 819w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-7-300x127.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-7-768x324.png 768w\" sizes=\"(max-width: 371px) 100vw, 371px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-9.png\" alt=\"\" class=\"wp-image-4766\" width=\"374\" height=\"201\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-9.png 617w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-9-300x161.png 300w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/figure>\n\n\n\n<p>.wj-cell{<br>background: lightgray;<br>}<\/p>\n\n\n\n<p>.rowcolor{<br>background-color: white;<br>}<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Next, add the following code to the JavaScript in ClientAction to complete the process.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"395\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-13-1024x395.png\" alt=\"\" class=\"wp-image-4771\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-13-1024x395.png 1024w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-13-300x116.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-13-768x297.png 768w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-13.png 1085w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>\/\/Set format for the acquired Grid<br>grid.itemFormatter = function(panel,r,c,cell){<br>\/\/Color the Email column (3rd column) with white<br>\u3000\u3000if(c === 2 ){<br>\/\/Add class definition to cell<br>wijmo.addClass(cell,&#8217;rowcolor&#8217;);<br>}<br>};<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"510\" src=\"https:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-11-1024x510.png\" alt=\"\" class=\"wp-image-4768\" srcset=\"http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-11-1024x510.png 1024w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-11-300x149.png 300w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-11-768x382.png 768w, http:\/\/dandelions.co.jp\/blog\/wp\/wp-content\/uploads\/2024\/03\/image-11.png 1041w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption>You can now color only the specified columns!<\/figcaption><\/figure>\n\n\n\n<h2>Summary<\/h2>\n\n\n\n<p>As you can see, OutSystems provides a variety of properties, but I found that you can implement them the way you want by using JavaScript.<br>It felt like I was able to reach out to a specific area of concern, and I felt that the scope of development was expanding.<\/p>\n\n\n\n<p>Why not consider using JavaScript if you cannot achieve the desired results using Outsystems properties alone?<\/p>\n\n\n\n<p>In the second unit, we will continue to develop blogs for engineers using low-code tools such as OutSystems, so please look forward to it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As an engineer blog, I would like to introduce the learning content that I am working on on a daily basis.This &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/dandelions.co.jp\/blog\/blog\/2024\/03\/21\/leveraging-javascript-in-outsystems\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Leveraging JavaScript in Outsystems&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[8],"tags":[9],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paR9rw-1f4","_links":{"self":[{"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4778"}],"collection":[{"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=4778"}],"version-history":[{"count":1,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4778\/revisions"}],"predecessor-version":[{"id":4781,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/posts\/4778\/revisions\/4781"}],"wp:attachment":[{"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=4778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=4778"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dandelions.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=4778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}