none
Is there a control that I can use to display document results similar to the ootb document listing?

คำตอบ

ตอบทั้งหมด

  • Hello,

    I don't think the is an oob feature to do this but you can use the oob listviewwebpart in your custom webpart and change the query before displaying it!

    I've made a topic about that here : http://christopherclementen.wordpress.com/2012/04/02/filter-a-list-dynamically/

    Hope this help!


    Best regards, Christopher.
    Blog | Mail

    • ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 11 พฤษภาคม 2555 8:30
    27 เมษายน 2555 17:37
    ผู้ตอบ
  • You can use ListViewByQuery control!

    Also there are similar controls: SPGridView and ListView.


    Don't happy, be worry...

    • ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 11 พฤษภาคม 2555 8:30
    27 เมษายน 2555 18:10
  • Can I use it for multiple library query like the

    SPSiteDataQuery spQuery = new SPSiteDataQuery();
    spQuery.Webs = "<Webs Scope=\"SiteCollection\">";

    .......
    spQuery.Lists = "<Lists>
                                   <List>......</List> <List>......</List>
                            <Lists>";

    ............................


    M Sariman RKO Business Solutions Inc.

    27 เมษายน 2555 23:04
  • Thanks Chris,

    ***************************************************

    1)  I got the grid displayed using your method but I'm getting errors when hovering on the list, pointing me to this when I debug

    function anonymous() {
         setupFilterMenuContext(ctx1);
    }

    or

    function anonymous() {
    setupMenuContextName('ctx1');
    }


                SPSite site = new SPSite(SPContext.Current.Web.Url);
                ListViewWebPart wp = new ListViewWebPart();
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Reference Documents"];
                    ListViewWebPart lvwp = new ListViewWebPart();
                    lvwp.ListName = list.ID.ToString("B").ToUpper();
                    lvwp.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(lvwp.ListViewXml);
                    XmlNode queryNode = doc.SelectSingleNode("//Query");
                    XmlNode whereNode = queryNode.SelectSingleNode("Where");
                    if (whereNode != null) queryNode.RemoveChild(whereNode);
                    XmlNode newNode = doc.CreateNode(XmlNodeType.Element, "Where", String.Empty);
                    newNode.InnerXml = query.ToString();
                    queryNode.AppendChild(newNode);
                    lvwp.ListViewXml = doc.OuterXml;

                    pnlResults.Controls.Add(lvwp);
                }

    Do I need to do anything else here?

    ***************************************************

    2) This will only work with one list only right?
        My requirements is to use SPSiteDataQuery where the query can search more than one document library.

    Thanks


    M Sariman RKO Business Solutions Inc.

    28 เมษายน 2555 0:22
  • 1) What kind of error have you? have you some message?

    2) yes it's working only with one list . 

    maybe you can investigate this topic : http://code.msdn.microsoft.com/sharepoint/Ejemplos-sobre-cmo-usar-el-69cd5f16

    It's seem to be what you are looking for.

    Hope this help!


    Best regards, Christopher.
    Blog | Mail

    • ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 11 พฤษภาคม 2555 8:30
    28 เมษายน 2555 6:33
    ผู้ตอบ
  • By the way,

      How do I fix this issue.
    When I display without intercepting the  whereNode I got all the records displayed.
    But when I started to intercept the query I'm getting this error.

    "One or more field types are not installed properly. Go to the list settings page to delete these fields".

    *********************************

               string query = GenerateCAMLQueryText();
              // this generates - <Where>
                                             <Or>
                                                <Eq>
                                                    <FieldRef Name=\"FBCKbWorkProcess\" LookupId=\"TRUE\" />
                                                    <Value Type=\"Lookup\">12</Value></Eq><Eq>
                                                    <FieldRef Name=\"FBCKbWorkProcess\" LookupId=\"TRUE\" />
                                                   <Value Type=\"Lookup\">21</Value>
                                                </Eq>
                                            </Or>
                                         </Where>
                

                SPSite site = new SPSite(SPContext.Current.Web.Url);
                ListViewWebPart wp = new ListViewWebPart();
                using (SPWeb web = site.OpenWeb())
                {
                    SPList list = web.Lists["Reference Documents"];
                    ListViewWebPart1.ListName = list.ID.ToString("B").ToUpper();
                    ListViewWebPart1.ViewGuid = list.DefaultView.ID.ToString("B").ToUpper();

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(ListViewWebPart1.ListViewXml);
                    XmlNode queryNode = doc.SelectSingleNode("//Query");
                    XmlNode whereNode = queryNode.SelectSingleNode("Where");
                    if (whereNode != null) queryNode.RemoveChild(whereNode);
                    XmlNode newNode = doc.CreateNode(XmlNodeType.Element, "Where", String.Empty);

                    newNode.InnerXml = query.ToString();
                    queryNode.AppendChild(newNode);
                    ListViewWebPart1.ListViewXml = doc.OuterXml;
                    ListViewWebPart1.Visible = true;
                
                }


    M Sariman RKO Business Solutions Inc.

    30 เมษายน 2555 21:04
  • sorry for the delay, I didn't seen your response..

    the error : "One or more field types are not installed properly. Go to the list settings page to delete these fields".  is often cause by the name of the field you try to query .

    are you sure that the field name  FBCKbWorkProcess is correct?

     


    Best regards, Christopher.
    Blog | Mail

    • ทำเครื่องหมายเป็นคำตอบโดย Shimin Huang 11 พฤษภาคม 2555 8:30
    7 พฤษภาคม 2555 8:34
    ผู้ตอบ