Search code examples
movilizer

How to show message in Movilizer data grid if no records found


I am using data grid in movilizer screen with question type = "9". Here i am binding data to grid with local array data. I want to show message in the grid screen 'No records found' if there is no data. how to show message in the middle of the screen here. below is my sample code

<question key="Item_Question" type="9" title="Item Details" tableOptionsEnabled="false" >
    <answer nextQuestionKey="END" key="Item_1" clientKey="0" colIndex="0" colWidth="5" attributeType="8" dummyAnswer="true">
      <text>Item ID </text>
    </answer>
    <answer nextQuestionKey="END" key="Item_2" clientKey="0" colIndex="1" colWidth="5" colSearchable="false"
            attributeType="8" dummyAnswer="true" valueAlignment="CENTER">
      <text>Item Description</text>
    </answer>

    <onEnterAssignment>
      itemCount = $local:itemDetails;

      for(clientKey : itemCount){
      Seq = concat(itemCount[clientKey]['ID'], '_', itemCount[clientKey]['Name']);

      addAnswer($answer:"Item_1", Seq, itemCount[clientKey]['ItemCode']);
      setAnswerValueByClientKey($answer:"Item_1", Seq, itemCount[clientKey]['ItemCode']);

      addAnswer($answer:"Item_2", Seq, itemCount[clientKey]['ItemDescription']);
      setAnswerValueByClientKey($answer:"Item_2", Seq, itemCount[clientKey]['ItemDescription']);

      }
    </onEnterAssignment>
  </question>

Thanks


Solution

  • You have lot of possibilities here. First one is include a new entry in the dummy answer with that message, like this:

    addAnswer($answer:"Item_1", "_Blank", "No records found");
    setAnswerValueByClientKey($answer:"Item_1", "_Blank", "No records found");
    addAnswer($answer:"Item_2", "_Blank", "");
    setAnswerValueByClientKey($answer:"Item_2", "_Blank", "");
    

    Another option is include a placeholder in question text element, and make it appear or dissapear if the local array has elements or not, just like this:

    <text>%MY_MESSAGE%</text>
    
    <onEnterAssignment>
      itemCount = $local:itemDetails;
    
      if (count($local:itemDetails) ?eq 0)
      {
        setPlaceholder("%MY_MESSAGE%", "No records found");
      }
      else
      {
        setPlaceholder("%MY_MESSAGE%", "");
      }
    
    </onEnterAssignment>
    

    And, if you are developing with 2.6 version, maybe another option should be use the showDialog method. It will show a box like a warning message in your movilizer client. Here is an example:

    showDialog(1, false, "Message title", "No records found", 14);