Endlessly Nesting <div> Ntawv cim npe thiab jQuery

Qhov no xws li tej tus oddball npe nkawd, Kuv tsis paub hais tias nws yog yeej muaj nqis blogging txog, tab sis cov uas ib txwm tsis lawm ua ntej kuv, yog li no peb yuav mus Luag nyav

Kuv tabtom haujlwm rau ib qhov project uas kuv tabtom rub tau tej ntaub ntawv los ntawm ib tug mus nrhiav, packaging nws rau hauv ib cov lus XML thiab ces tus XML yog kawg transformed rau HTML ntawm XSLT.  Muaj coob heev jQuery muab kev koom tes, ib ntsis uas implements tej cov tabbing functionality.  Thaum twg koj nyem rau ntawm ib tug tab (tiag tiag, ib tug <div>), jQuery invokes .hide() thiab .show() nyob rau ntau yam divs (cov nplooj pib load downloads cov ntsiab lus txhua yam thiaj li muaj muaj tsis muaj postbacks qhov no).

Ib Rev teev dhau los, tus tab switching logic pib coj erratically thiab nws tsis qhia ib qho kuv tabs.  Kuv kawg tracked nws mus txog ntawd qhov internet explorer (tsawg) xav hais tias tus <div> cim npe nested deb deb, deb ntxaum dua intended.Tus tsim tawm toolbar yuav qhia:

-<div daim id = "Tab1Content">
  -<div>
    -<div>
      -<div daim id = "Tab2Content">
        -<div>
           …………………………
                   </div>  <— kaw thaum kawg uas qhia nws tag kev cia rau no!

Li ntawd, Yog hais tias kuv ua ib $("#Tab1Content").nkaum(), Kuv kuj xav nraim Tab2 thiab kuv yuav tsis pom Tab2 yog hais tias kuv tsis tau qhia Tab1.  Tau theej thiab Document lub chaws rau studio siv qhov muag saib thiab nws yuav tsom hauv ob sab qhov div phlu tuaj tag nrho nicely, li lawv thiab yuav tau ua, saib zoo li no:

-<div daim id = "Tab1Content">
  +<div>
  +<div>
-<div daim id = "Tab2Content">
  +<div>
  +<div>

Tuav kuv lub taub hau tiv thaiv phab ntsa ib pliag thiab pom tau tias nyob hauv lub txoos HTML code tau generating empty heev <div> cim npe, zoo li:

<lub cev>

  <div daim id = "Tab1Content">

    <div daim id = "row1" />
    <div daim id = "row2" />

  </div>

  <div daim id = "Tab2Content">

    <div daim id = "row1" />
    <div daim id = "row2" />

  </div>

</lub cev>

(Cov saum no yog waaaaaaaaaaaay oversimplified.  Qhov khoob div cim ua npe yog siv tau lig. Qee yam ntawm kuv <div> cim npe tau tag nrho cov ntsiab lus, tab sis coob tshaj ntawd twb tsis tau.  Kuv tuaj hauv realization uas kuv <xsl:rau-ib> kev tswj tau emitting lub luv-daim ntawv div tags thaum twg tus xsl:rau-ib tsis ' nrhiav tej ntaub ntawv no.  Kuv yuam ua qhov HTML saib mus rau hauv lub qhov zis, li:

image

 

Tom qab kuv puas tau tias, tag nrho cov div lub lined nicely thiab kuv tab switching pib ua hauj lwm.

Li ib txwm, Kuv vam tias qhov no yuav pab lwm tus neeg nyob hauv lub pinch.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Quick Fix: "Lub npe qha hom lub$ Resources:ReportServerResources … tsis xyaw … cov cim tshwj xeeb”

Kuv twb tau yos ib co tu tuaj ib SharePoint 2010 kawm ntawv thiab yog ib qhov teeb meem txog tu tej koom ib corrupt / incorrectly ntsia SQL neeg rau zaub mov daim ntawv qhia txog cov kev pab no.  Qhov no sawv thaum ib tus kuv lug txhawb cov miv sim kom tseg tau ib qhov chaw li ib template thiab ces tsim tsim tau ib qhov chaw tshiab raws li ntawd template.  Txuag tau rau lub lag luam ua haujlwm fine, tab sis, thaum twg nws sim ua kom muaj qhov chaw tshiab, SharePoint tso tawm kom pom kev ua yuam kev hais nram qab no:

Yuam kev

Cov hom kawm ntawd npe ' $Resources:ReportServerResources,DataSourceContentTypeName;' tsis muaj: \ / : * ? “ # % < > { } | ~ & , dua ob tug sib law liag (..), los yog kev cim tshwj xeeb xws li ib tug tab.

Ntawm no yog ib qho screen CAP ib tug:

 

image

Muaj ib hom kawm ntawd saib nyob rau hauv lub site thiab nrhiav tau qhov no:

image

Cov kawm ntawd txoj kev no tsis zoo hais meej.

No qhov teeb meem rau nkawd tuaj heev nyob rau lub Internets thiab muaj tsis kom zoo tau muaj kev pom zoo nkaus xwb thiaj li daws tau.  Kuv pom ib ke rooj uas mapped rau lub npe phem cov hom rau cov hom npe ntawm no: http://social.technet.microsoft.com/Forums/en-ZA/sharepoint2010programming/thread/cb03e866-8184-4943-acfe-cafffa1b8b7a.  Kuv manually tshiab lawv thusly:

image

(BrightStarr lub npe yog yeem obviously, tab sis nws tsis tau ua Luag nyav )

Qhov no pub kuv mus tsim ib cov template tshiab thiab tsis khis txhua yam nyob rau lwm qhov chaw, xws li ib co khoom PerformancePoint neeg rau zaub mov uas yog ib pab neeg txawv kiag li tau ua haujlwm rau.  Kuv twb ces tau los ua ib qhov chaw tshiab rau lub template.  Zoo!

Kuv tsis paub hais tias qhov no yog ib tug 100% tov, tab sis, nws tau kuv thiab koom tes sawv daws nrog yav tas los no annoying yuam kev.  Yog kuv nrhiav tau tej yam tshiab, Kuv mam li tswg ib qho hloov tshiab.  Kuv nervousness stems ntawm tus fact tias cov npe tsis raug lawm ua tus xub place thiab kho qhov lub npe zaub, Kuv yuav tsis kov lub npe nrog. 

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Ib tug ua rau "tus creator ntawm qhov kev txhaum ho tsis qhia ib vim li cas.”

Kuv twb tau ua hauj lwm SharePoint nrhiav lately thiab lawv cov KeywordQuery kawm ntau, khoom thiab txoj kev.

Yog hais tias koj xav tau tus raug tso rov qab tau above and beyond lub suspects li ib txwm (saib ntawm no), koj ntxiv nws lub SelectedProperties sau, raws li nyob rau hauv:

myKeywordQuery.SelectProperties.Add("xyzzy");

Tsaug ntau thiab ib lub kaus mom rau taub Corey Roth thiab no cov ncej tswv enormously blog (http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/02/19/how-to-use-the-moss-enterprise-search-keywordquery-class.aspx)

Hauv kuv tsev neeg, "xyzzy" tsis yog ib tug muaj managed long-term ua tau.  Thaum twg kuv ntxiv nws rau SelectedProperties lawm, SharePoint txawb kuv favorite ib puas runtime ntxiv:

"Tus creator ntawm qhov kev txhaum ho tsis qhia tias koj thiab."

Kuv pheej nyiam lub peev "R" nyob rau hauv vim li cas.  Qhov no kuv suab zoo li .NET sib npaug ntawm"Kuv muaj tsis muaj qhov ncauj, thiab kuv yuav tsum tau scream.”

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Tej kev siv ncaj: Pheej tawm ntawm kev tshawb KeywordQuery

Ua tau rau thaum koj tus tus Execute() txujci nyob ib KeywordQuery, koj muaj peev xwm tsim ib ResultTable le ResultType.RelevantResults.  No lub snippet code illustrates kuv txhais li cas:

ResultTableCollection resultsTableCollection = myKeywordQuery.Execute();

ResultTable searchResultsTable = resultsTableCollection[ResultType.RelevantResults];

Lub rooj resulting yuav muaj rau txhua cov lus nram qab no: 

WorkId
Plaws
Npe
Sau
Loj
Kab
Hauj lwm lawm
Sau ntawv
SiteName
CollapsingStatus
HitHighlightedSummary
HitHighlightedProperties
ContentClass
IsDocument
PictureThumbnailURL
ServerRedirectedURL

Kuv derived daim ntawv los ntawm ib cov SharePoint 2010 ib puag ncig, ib tsab Enterprise.  Hopefully nws yuav ua ke rau ib tug neeg yav.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Vim li cas ib tug rau: "Tejyam extract cov ntaub cab hauv cov kua”

Tswvyim thaum uas ua hauj lwm los ntawm siv qhov muag saib lub studio Web site qhov npaj hnub no, Kuv puas tau ib tug me re-nrog rau tej ntaub ntawv yuav muab tso rau hauv lub _layouts sis ib feem ntawm txheej txheem txiag. Yeej, Kuv renamed ib .js thov los ntawm "TypeAhead.js" los "TypeAhead(laus).js"  Kuv yuav npaj ua kom tshem nws thaum nws successor "TypeAhead.js" proves puas muaj tseeb.  Nws zoo li no:

image

Qhov no tam sim ntawd vim ib qho teeb meem uas siv qhov muag saib lub studio thaum kuv sim deploy rau peb tes num:

Yuam kev tshwm sim txiag kauj ruam 'Ntxiv kua': Tejyam uas extract tsheb tav xis cov ntaub ntawv nyob rau hauv txoj kev hais haum.

Nws puv kom paub tias koj yuav tsis tso ib tug parenthesis npe rau cov ntaub ntawv.  Kuv tshem tawm cov parens thiab solved qhov teeb meem uas.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Tsis tau ntxiv jQuery–Resize ib qho piv txwv ua tus duab

Kuv pub ib cov qhov Web site ntawm ib tug neeg laus vendor thiab yuav ua tau ib qho teeb meem loj, me duab.  Cov dluab yuav tsum muaj 60×50 tab sis vim khib, tus thawj vendor yuam lawv ua 42×42, li ntawd, lawv nrhiav squashed:

 

Cov duab zoo

Teeb duab

Ntawm no yog cov markup (dog dig yooj yim zog):

<table hoob = 'ncua-outlook'>
  <thead>
    <tr>
      <th  dav ='100′>3 Tuesday</th>
    </tr>
  </thead>

  <tbody>
    <cov chav kawm tr = 'huab cua'>
      <Td dav ='100′>
        <ul>
          <lis hoob = 'high'>Siab: 72&deg;F</lis>
          <lis hoob = 'low'>Qes: 44&deg;F</lis>
          <lis hoob = 'mob'>Tshav ntuj
            <img src =’
http://deskwx.weatherbug.com/images/Forecast/icons/localized/60×50/en/Trans/cond007.png’ dav ='42’ qhov siab ='42’ xwm =” />
          </lis>
        </ul>
      </Td>
    </tr>

  </tbody>

</cov lus>

Koj mam li nco tias txawm ho lub kev ua kom cov duab xwb qhia qhov kom zoo dimension (60×50) tus thawj vendor yuam nws hauv 42×42.  Ua li cas?  Vwm.

Xijpeem, Kuv xav tau txoj kev sai thiab yooj yim tov rau no qhov teeb meem thiab kuv muab rau jQuery.  Qhov ua kom yuam kev los nrhiav tau txhua yam txog qhov tsim nyog tau <img> cim npe.  Kuv tsis xav muck cov cim kev lwm img npe (cov uas muaj ntau ntau).  JQuery no me ntsis puas tau qhov ua kom yuam kev:

<Script yam = "ntawv nyeem/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></tsab ntawv>

<Script yam = "ntawv nyeem/javascript">
     $(daim ntawv).npaj txhij(muaj nuj nqi () {

         $(' li.condition > img').txhua(muaj nuj nqi (Performance Index, yam khoom)
           
{
             $(yam khoom).CSS("dav", "60"); 
             $(yam khoom).CSS(qhov "siab", "50");
            });
     }); // nyob rau daim ntawv load
</tsab ntawv>

Chaws ntawd me ntsis pom qhov sau los ua <lis> cim npe cov hoob kawm uas nws yog "mob" thiab <img> cov me nyuam.  Nws mam li iterates los ntawm tag nrho cov neeg ntawd.  Ua haujlwm zoo li ib lub nplhaib.

Kuv yuav zaum khiav nws, tab sis kuv yeej tsis muaj ib hom txiv leej tub unix tias solved π mus 18 xaus-npawb tsab precision sed thiab cov awk thiab kuv tsis ntawd seb yog jQuery guy tog twg los Luag nyav.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Parsing XML nrog LINQ

Ntawm no yog tus ceev kev piv txwv uas siv cov LINQ los parse ib co  XML thiab mus rau hauv lub qab zib, qab mib attributes therein.

Nov yog lub XML kuv xav parse:

<?xml version = "1.0 Tub ntxhais" encoding = "utf-8" ?>
<DeafultConfigurationSets>
  <PageLayouts>

    <PageLayout npe = "xyzzy">
      <Tabs>
        <Tab TabOrder = "1" TabLabel = "x" SharePointContentType = "ib" AdditionalConstraints = "ac1" />
        <Tab TabOrder = "2" TabLabel = "y" SharePointContentType = "b" AdditionalConstraints = "ac2" />
      </Tabs>
    </PageLayout>

    <PageLayout npe = "xyzzy2">
      <Tabs>
        <Tab TabOrder = "100" TabLabel = "x" SharePointContentType = "ib" AdditionalConstraints = "ac1" />
        <Tab TabOrder = "101" TabLabel = "y" SharePointContentType = "b" AdditionalConstraints = "ac2" />
        <Tab TabOrder = "103" TabLabel = "z" SharePointContentType = "c" AdditionalConstraints = "ac3" />
      </Tabs>
    </PageLayout>

  </PageLayouts>
</DeafultConfigurationSets>

Kuv xav tau ib co tabs tom runtime tsim los ntawm parsing cov saum no.  Kuv tabs vam li ib phab layout.  Yog kuv tus nplooj layout lub npe hu ua "xyzzy2" ces kuv xav tau tabs 100, 101 thiab 103 (tus tabs hauv <PageLayout npe = "xyzzy2">).

Ntawm no yog cov LINQ uas yog nws:

Var allTabs =
              ntawm p hauv
                  XElement.Parse(theXmlToParse).
                 
Ntsiab("PageLayouts").
                  Ntsiab("PageLayout")
              nyob qhov twg (p.Attribute("lub npe").Value.Equals("xyzzy2"))
              ntawm m hauv p.Elements("Tabs").Ntsiab("Tab")
              xaiv m;

          Results.Text = hlua.Npliag;

          foreach (Var aTab nyob allTabs)
          {
              Results.Text =
                  "Kev txiav txim tab: " + aTab.Attribute("TabOrder").Tus nqi + " |" +
                  "Tab lo cim: " + aTab.Attribute("TabLabel").Tus nqi + " | " +
                  "SharePointContentType: " + aTab.Attribute("SharePointContentType").Tus nqi + " | " +
                  "AdditionalConstraints: " + aTab.Attribute("AdditionalConstraints").Tus nqi + "r";
          }

Nyob rau saum no, kuj sib txawv rau thiab "theXmlToParse" yog ib txoj hlua kuj sib txawv thiab, tab sis, koj yuav tau siv cov load() txoj kev ntawm ib tug kwj yog hais tias koj nyiam.

"Tau" yog ib daim ntawv lo ntawm cov qhov web daim ntawv thiab thaum cov code no executes, nws zoo li no:

SNAGHTML11cd2e7c

Kuv tsis tau ua haujlwm tawm yuav txheeb soj ntsuam tsis tau li cas, li ntawd, kuv ces cia ntawd rau tus tom ntej blog ncej.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

SharePoint 2010 KeywordQuery thiab cov neeg siv cov Anonymous

Kuv enabled anonymous mus saib hauv qhov chaw kuv yuav ntsuam xyuas seb tus nrhiav Web site qhov kuv twb tau tsim thiab tsis muaj cov poj surprise, Nws kuj luv.  Anonymous ntawv yeej zoo nkauj npaum li cas yog muaj kev sib tw rau kuv.

Qhov no, tsis mus nrhiav qhov pib tsis khiav vim.  Kuv yuav tsum hais tias nws heev running tab sis nws twb tsis rov muaj lub ntsiab.  Kuv siv kuv cov KeywordQuery rau ntawd cov zaub pib.

Kuv puas tau ceev teem ib lub caij mus nrhiav thiab no ncej blog los"sowmyancs"tuaj haum sai sai: “SharePoint 2010 Nrhiav: tsis uas qhia cov kev tshwm sim rau anonymous cov neeg?”  Tias blog nkag piav qhov teeb meem los ntawm tus tawm ntawm lub thawv lo lus tseem ceeb mus nrhiav foundations tab sis tus cwj pwm ntawd zoo li kuv li – nws ua haujlwm rau cov neeg siv cov authenticated thiab rau cov neeg siv cov anonymous, tab sis cov neeg siv cov anonymous txais tsis tau. 

Kuv raws li cov lus qhia thiab cov bang!  Nws solved kuv qhov teeb meem.  Kuv tsis paub dab tsi phiv no yuav muaj thiab lawv yuav pom tau ib qho teeb meem, tab sis, cov me ntsis lub sij hawm no yuav pab tau.

Nyem rau ntawm qhov blog:

image

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

SharePoint 2010 KeywordQuery thiab ntiag HiddenConstraints

Kuv twb tau ua me ntsis hauj lwm nrog cov KeywordQuery kwv nyob SharePoint 2010 making ua tus HiddenConstraints khoom.

Kuv tsis nrhiav yam tam sim ntawd xov tooj rau qhov uas cuab yeej, ces kuv xav tias kuv yuav ceev nrooj jot cia li kuv twb tau siv nws.

Raws li kuv tau qhia, qhov no yog ib qho tsis zoo no feem constraint ntxiv rau cov lus nug kom thiaj txheeb ntawm cov chaw ua si ntawd muaj thiab tsis txhawj txog nws.  Zoj, Nws yog ib lo lus tseem ceeb rau lwm xwb (los yog txheej keywords) thiab modifiers uas koj tau ntaus nyob rau daim UI thaum koj ua ib lo lus tseem ceeb nrhiav.  Ntawm no yog ib qho piv txwv:

keywordQuery.HiddenConstraints = "tau:\"Industry" ";

Koj ntxiv tau kev xyuas ntxiv nrog rau ib qhov chaw delimiter.

keywordQuery.HiddenConstraints = "tau:\"Industry" kws muaj txuj ci";

Cov saum no yog hais rau hauv Hmong, "khiav ib lus nug lo lus tseem ceeb rau cov kws muaj txuj"ci"thiab tas, siv qhov "Kev lag luam" tau.

Ntawm no yog ib txoj kev saib nws:

image

Kuv twb tau siv ntawd los muab lub ntsiab lus teb-his tuaj tau rau ib lub qhov Web site rau kev cai.  Thaum cov neeg clicks nyob rau ib lub tab thiab clicks tus nrhiav khawm, tus tab dictates ib tug mus nrhiav tau.  Nws yuav ua zoo li ntawd, nyob deb.

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin

Piv txwv: XSLT tsim HTML Href tus

Kuv twb tau ua me ntsis XSL khoom lately thiab xav tias kuv yuav muab sib dhos ib tug qauv rau kuv cov neeg siv yav tom ntej thiab uas tej zaum yuav nqis los rau peb sawv daws XSLT-ers ua ib tug nyob hauv cov internets.

Xav txog cov lus hauv qab no XML:

<FdcSearchTabsCollection suav = "2">
  <SearchTab daim ntawv lo = "kev lag luam" SortOrder = "00" daim ntawv lo = "Industries" SearchConstraints = "contenttype:Kev lag luam" TabID = "831b2a74-98c4-4453-8061-86e2fdb22c63" />
  <SearchTab daim ntawv lo = "txoj kev" SortOrder = "01" daim ntawv lo = "Practices" SearchConstraints = "contenttype:PracticeGroups" TabID = "678e206b-6996-421f-9765-b0558fe1a9c0" />
</FdcSearchTabsCollection>

Cov lus hauv qab no XSL snippet yuav tsim ib daim ntawv teev sorted txog hrefs tabs:

<xsl:Template match = "FdcSearchTabsCollection" xml:chaw = "khaws cia">
   
    <!– "Tagnrho cov" tab –>
    <ib tug href = "javascript:ViewTab('Txhua')">Saib tag nrho cov</ib tug>
   
    <!– Txhua tus neeg tab –>
    <!– Iterate los ntawm tag nrho cov Tabs thiab tso saib qhov tseeb  kev mus. –>
    <xsl:rau-ib qho = "SearchTab">
      <xsl:tsi select="@SortOrder"/>

      …
      <ib tug href = "javascript:ViewTab(‘{@ TabID}’)"><xsl:tus nqi-cov select="@Label"/></ib tug>
    </xsl:rau-ib>

    <br /> 
   

   </xsl:Template>

Nov yog qhov nws zoo li hauv SharePoint:

SNAGHTML78aa2cb

 

 

</kawg>

Subscribe rau kuv blog.

Raws li kuv nyob Twitter tom http://www.twitter.com/pagalvin