Manipulating Smart Office Column Header Filter Values

[updated the formatting of the code]
I saw an interesting question raised about manipulating the values in the Column Headers of a ListView within Smart Office, can it be done. Well, after playing around with Reflect and Smart Office I figured it could as all of the properties can be happily reflected.

Anyway, the program in question was: CRS610 and following is the code, the code is fairly rough, but functional. (I’ve left the MessageBox.Show() calls in there to illustrate what the objects are)

import System.Windows;
import System.Windows.Controls;
import MForms;
import Mango.UI.Core;
import Mango.UI.Core.Util;
import Mango.UI.Services;

package MForms.JScript {

class TestControl
{
 var debug, button, content, win, lv, listControl;
 var click;
 public function Init(element: Object, args: Object,controller : Object, debug : Object)
 {
  // control = controller;
  content = controller.RenderEngine.Content;
  listControl = controller.RenderEngine.ListControl;
  lv = listControl.ListView;
  button = new Button();
  button.Content = "Inject";

  Grid.SetColumnSpan(button, 10);
  Grid.SetColumn(button, 0);
  Grid.SetRow(button, 1);
  content.Children.Add(button);
  button.add_Click(OnClick);
  button.add_Unloaded(OnUnloaded);

  click = false;
 }

 public function OnClick(sender: Object, e: RoutedEventArgs)
 {
  var columns = lv.Columns;
  var gvGridView = lv.View;

  try
  {
   if(null != gvGridView)
   {
    MessageBox.Show("We have a GridView");
    var strColumnText;
    for(var i=0; i < gvGridView.Columns.Count; i++) // loop through the columns
    {
     if(null != gvGridView.Columns[i].Header) // verify we don't have a null
     {
      MessageBox.Show(gvGridView.Columns[i].ToString());    // show the type of the object
      try
      {
        MessageBox.Show(gvGridView.Columns[i].Header.ToString());    // show the type of the object
        MessageBox.Show(gvGridView.Columns[i].Header.Content.ToString());    // show the type of the object

        if(i <= 2) // I do this so we only change the values of the first two columns
        {

    // we know that we have a TextBox and that the Text property contains the value, so we set it to whatever we desire
         gvGridView.Columns[i].Header.Content.Children[1].Text = "Potato";
        }
       }
       catch(ex)
       {
        MessageBox.Show("Exception: " + ex.Message);
       }
      }
     }
    }
   }
   catch(ex)
   {
    MessageBox.Show("Exception: " + ex.Message);
   }
 }

  public function OnUnloaded(sender: Object, e: RoutedEventArgs)
  {
   button.remove_Click(OnClick);
   button.remove_Unloaded(OnUnloaded);
  }
 }
}
This entry was posted in Development, M3 / MoveX. Bookmark the permalink.

3 Responses to Manipulating Smart Office Column Header Filter Values

  1. KRC says:

    Please help thru this issue at earliest below is my requirement:
    If any value on E Panel of PPS171 is changed then automatically the Status field should change from ’10’ to ’20’ .and one more thing we user comes on E panel the values on Epanel should be saved and after pressing NEXT the value on the E panel should be checked with the initial values if any of the value does not match then status should be changed to ’20’.

  2. Pingback: Filtering and ListViews – PositionFields | Potato IT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s