Jump to content
Software FX Community

Only show added items?


jtadros
 Share

Recommended Posts

I'm sure this is pretty easy once the documentation and examples are completed but at the moment it is somewhat confusing.  Here's the issue, I have a datasource that is created from an ArrayList which comes from a third party Webservice. The webservice returns null or default entries when it is called.  Now when I pull data and then add the columns as shown below.  I still get the rest of the columns that I really do not want to show.  Is there anyway to simply have an empty grid to start except for Grid1.Fields.Add items? I was able to do this by binding the dataset and then turning off columns but then I would have to create a pretty robust sort. In that scenerio I was unable to convert a url field into an image field easily.  Code listed below

This works great but lists all the data elements after the added ones.

  Media[] objects = myClient.Service.getMedia(template, query, sort, range);

  ObjectArray objectArray = new ObjectArray(objects);

  DataSet ds = new DataSet();

  ds = objectArray.ToDataSet();

  Grid1.DataSource = ds;

Grid1.Fields.Clear();

  Grid1.Columns.Clear();

  GridFX.WebForms.TextField media_idField = new GridFX.WebForms.TextField();

  GridFX.WebForms.ImageField imageField = new GridFX.WebForms.ImageField();

  GridFX.WebForms.TextField titleField = new GridFX.WebForms.TextField();

  GridFX.WebForms.TextField authorField = new GridFX.WebForms.TextField();

  GridFX.WebForms.TextField lengthField = new GridFX.WebForms.TextField();

  GridFX.WebForms.TextField ratingField = new GridFX.WebForms.TextField();

  titleField.DataPath = "title";

  imageField.DataPath = "thumbnailURL";

  authorField.DataPath = "author";

  lengthField.DataPath = "length";

  ratingField.DataPath = "rating";

  media_idField.DataPath = "media_id";

  Grid1.Fields.Add(media_idField);

  Grid1.Fields.Add(imageField);

  Grid1.Fields.Add(titleField);

  Grid1.Fields.Add(authorField);

  Grid1.Fields.Add(lengthField);

  Grid1.Fields.Add(ratingField);

 This Works better by hiding elements but of course then they have to be sorted and I was not able to get Grid1.Fields.Add to work nor could I change a column to work with an imageField.

Media[] objects = myClient.Service.getMedia(template, query, sort, range);

  ObjectArray objectArray = new ObjectArray(objects);

  DataSet ds = new DataSet();

  ds = objectArray.ToDataSet();

  Grid1.Fields.Clear();

  Grid1.Columns.Clear();

  Grid1.DataSource = ds;

  Grid1.DataBind();

int[] cols = { 1, 6, 11, 25, 27, 38, 40, 42, 43 };

  gridHideAll();

  gridShow(cols);

Thanks for any help just to get us going as I understand this is still beta.

Link to comment
Share on other sites

Interesting.  The problem seems to come from clearing the Fields and Columns and then adding and re-binding.  I have logged it as an issue and it will be addressed in a future build.

An easy workaround to your problem is to add the fields and columns in the ASP markup, either through the markup directly or through the property grid.  The resulting grid markup would look something like this:

  <GridFX:Grid ID="Grid1" runat="server" >

  <Fields>

  <GridFX:TextField DataPath="title"></GridFX:TextField>

  <GridFX:ImageField DataPath="thumbnailURL"></GridFX:ImageField>

  <GridFX:TextField DataPath="author"></GridFX:TextField>

  <GridFX:TextField DataPath="length"></GridFX:TextField>

  <GridFX:TextField DataPath="rating"></GridFX:TextField>

  <GridFX:TextField DataPath="media_id"></GridFX:TextField>

  </Fields>

  <Columns>

  <GridFX:FieldColumn Field="title"></GridFX:FieldColumn>

  <GridFX:FieldColumn Field="thumbnailURL"></GridFX:FieldColumn>

  <GridFX:FieldColumn Field="author"></GridFX:FieldColumn>

  <GridFX:FieldColumn Field="length"></GridFX:FieldColumn>

  <GridFX:FieldColumn Field="rating"></GridFX:FieldColumn>

  <GridFX:FieldColumn Field="media_id"></GridFX:FieldColumn>

  </Columns>

  </GridFX:Grid>

Also, I would recommend using the ObjectDataSource to hook up to your data.  Was there a specific reason you were doing everything in code? 

Thanks so much.  I hope to hear back soon.

Steve Potter

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...