title: Grails - sorting g:sortableColumn with hasMany relation in scaffolding
body: <p>I have 3 domain classes:</p>
  
  <pre><code>class Material {
  String sku
  String description
  String uom
  String category
  String type
  double standardPrice
  
  static hasMany = [prices: Price]
  
      static constraints = {
          sku(blank:false, nullable:false)
          description(blank:false, nullable:false)
      }
  }
  
  class Price {
  
  double price
  
  static belongsTo = [material: Material, priceList: PriceList]
  
  
      static constraints = {
  
      }
  }
  
  class PriceList {
  String priceListName
  Date validFrom
  Date validTo
  Boolean isValid
  
  
      //static belongsTo = [supplier: Supplier]
      static hasMany =[prices: Price]
      static constraints = {
      }
  }
  </code></pre>
  
  <p>my PriceList update gsp is following:</p>
  
  <pre><code>&lt;%@ page contentType="text/html;charset=UTF-8" %&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/&gt;
  &lt;meta name="layout" content="main"/&gt;
  &lt;title&gt;Update price list&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;g:form name="priceListlUpdateForm" id="${priceListInstance.id}"&gt;
      &lt;div class="buttons" role="navigation"&gt;
              &lt;g:actionSubmit action="save" class="edit" value="Update"   /&gt;
              &lt;g:actionSubmit action="index" class = "cancel" value = "Cancel" /&gt;
              &lt;g:actionSubmit action="delete" class ="delete" value="Delete" /&gt;
      &lt;/div&gt;
      &lt;div class="body"&gt;
          &lt;h1&gt;Update price list&lt;/h1&gt;
      &lt;/div&gt;
      &lt;table&gt;
          &lt;tbody&gt;
              &lt;td&gt;Price list name&lt;/td&gt;
              &lt;td&gt;
                  &lt;g:textField name ="priceListName" value="${priceListInstance.priceListName}" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Valid From&lt;/td&gt;
              &lt;td&gt;
                  &lt;g:datePicker name="validFrom" precision = 'day' value = "${priceListInstance.validFrom}" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Valid To&lt;/td&gt;
              &lt;td&gt;
                  &lt;g:datePicker name="validTo" precision ='day' value = "${priceListInstance.validTo}" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;/g:form&gt;
  
      &lt;/tbody&gt;
  
  
      &lt;/table&gt;
  
  
      &lt;div class="constent scaffold-list" role=main&gt;
      &lt;h1&gt;Materials for price list&lt;/h1&gt;
          &lt;table&gt;
           &lt;thead&gt;
              &lt;tr&gt;
                  &lt;g:sortableColumn property="sku" title="SKU" /&gt;
                  &lt;g:sortableColumn property="description" title="Description"  /&gt;
              &lt;/tr&gt;
           &lt;/thead&gt;
           &lt;tbody&gt;
              &lt;g:each in="${pricesInPriceList}" status="i" var="pricesRow"&gt;
              &lt;tr&gt;
                  &lt;td&gt;${pricesRow.material.sku}&lt;/td&gt;
                  &lt;td&gt;${pricesRow.material.description}&lt;/td&gt;
              &lt;/tr&gt;
              &lt;/g:each&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>update in PriceList Controller is following:</p>
  
  <pre><code>def update(long id) {
          PriceList row=PriceList.get(id)
          def pricesInPriceList = row.prices
          [priceListInstance: row, pricesInPriceList: pricesInPriceList]
          //render "this is update controller"
      }
  </code></pre>
  
  <p>Everything is working fine except sorting.
  When I click sortablecolumn on sku or description sorting is not working (rows are sorted randomly).
  I stuck with this sorting. Thank you for help.
  Regards,</p>